Hello can somebody tell me what I am doing wrong?
1 次查看(过去 30 天)
显示 更早的评论
I am trying to run this function file but I keep getting am error. Okay so I have narrowed it down its the element by element operation that I can't get right for the equations [N,I,P,E]I'm running the values that go into the function from a separate script file.
function [N, I, P, E] = DCmotor(T,V,VN,NNL,INL,IS,TS)
%DCmotor calculates the motor performance using the following parameters and equations
%Input arguments:
%T = torque value in a range from 0 to VcTs % In gram-centimeters, g-cm
%V = supplied voltage % In volts, V
%VN = normal rated voltage % In volts, V
%Nnl = speed % In speed, rpm
%INL = current % In amps, A
%IS = current % In amps, A
%TS = torque % In gram-centimeters, g-cm
%Output argument:
%N = Speed % In revolutions per minute, rpm
%I = Current % In amps, A
%P = Power % In watts, W
%E = Efficiency % In percent, %
format compact
N=(VC.*NNL).*(1.-T)/(VC.*T);
I=VC.*INL+IS-INL*(T/TS); % In amps, A
P=1.635e-6.*(2.*pi)*(N.*T); % In watts, W
E=100.*P./(V.*I); % In percent, %
VN=12.00;
V=[12.0:24.0];
VC=V/VN;
TS=275;
T=linspace(0,235)
NNL=15700;
INL=0.3;
IS=4.09;
This is what I get:
Error using .*
Matrix dimensions must agree.
Undefined function or variable 'VC'.
Error in DCmotor (line 20)
N=(VC.*NNL).*(1.-T)/(VC.*T);
3 个评论
Image Analyst
2015-2-15
D'Monte, all your edit did was to add the error message. Like my answer before said (in my second answer), I figured that out and proposed a solution that seems to work. Does it not do what you want?
回答(2 个)
Image Analyst
2015-2-15
Are you going to tell us what parameters you passed in and what the error is? Or will you make us guess? Come on, make it easy for us to help you. Also, read this before you fix your post. Copy all the red text you see (if any) and paste it back in your fixed-up answer.
0 个评论
Image Analyst
2015-2-15
Well now you know how to format but you didn't tell me numbers to pass in so I had to make up some. And you didn't paste in the error message either like I asked. Read this for next time Anyway, I had some free time so I decided to see how far I get...
Here is the error message I got:
Undefined function or variable 'VC'.
Error in test3>DCmotor (line 24)
N=(VC.*NNL).*(1.-T)/(VC.*T);
Error in test3 (line 2)
[N, I, P, E] = DCmotor(1,2,3,4,5,6,7)
So it doesn't know what VC is. Did you notice that the VN in the function declaration had a squiggle under it saying that that variable is not being used inside the function? MATLAB puts squiggles under code that it has doubts about. And notice that the error says VC is undefined. So I assumed that VC should really be VN and once I made all the VC into VN, it gave results. Can you confirm that that is the cause of your problem? And mark my answer as "Accepted" if it is? Thanks in advance.
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Introduction to Installation and Licensing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!