matlab 金宝appsimulink错误帮助我

2 views (last 30 days)
Sutae
Sutae 2012年12月1日
嗨,我是韩国学生
Error occurs I use the matlab in simlunk
我实际上不确定为什么这个错误直到您不知道如何解决
请教我并帮助我Matlab Masters
code is
Msize is 1 X 181
Ws是恒定的
this code is matlab function's parameter in simulink
---------------------------------------------------------------------------------------------------------------------------
功能[D,cd]= fcn(S, W, M)
%#codegen
fori=1:181;
cl = w ./(0.5*2116.2*1.4*s*m.^2);
ifM(1,:)<=0.8 ;
cd0l=0.015;
k=1/(pi*6*0.7);
elseifM(1,:)>=1.2;
cd0l=(0.015+(3*0.015-0.015)*(sin((2*pi)/3))^3);
k =(1/(pi*6*(0.7-7*(0.4)^2+22*(0.4)^3)));
else
cd0l=(0.015+(3*0.015-0.015).*sin((M-0.8)./0.6*pi).^3);
k =(1 ./(pi*6*(0.7-7*(M-0.8)。^2+(m-0.8)。^3)。*22));
end
cd = cd0l+k。*cl。^2*一个(1,181);
d = 0.5。*CD。*1.4。*2116.2。*S.*M.^2;
--------------------------------------------------------------------------------------------------------------
我想要CD和D值的值。并播放Simulink,此金宝app错误是
Sizemismatch (size [:? x 1] ~= size [181 x 1]).
不匹配varying and fixed sizes indicate a probable run-time error.If this diagnostic is incorrect, 采用indexing to explicitly make the varying size fixed
请告诉我什么错误消失了

答案(2)

米奇·马特利(Mitch Martelli)
Hi, You use a for statement but I cant see no one indexed variable inside the loop. Maybe you would like to to this :
num_col = size(m,2);
fori = 1:num_col;
cl(i)=W./(0.5*2116.2*1.4*S*M(i).^2);
ifM(i)<=0.8 ;
cd0l(i)=0.015;
k(i)=1/(pi*6*0.7);
elseifM(i)>=1.2;
cd0l(i)=(0.015+(3*0.015-0.015)*(sin((2*pi)/3))^3);
k(i)=(1/(pi*6*(0.7-7*(0.4)^2+22*(0.4)^3)));
else
CD0L(i)=(0.015+(3*0.015-0.015)。*sin((m(i)-0.8)./ 0.6*pi)。^3);
k(i)=(1./(pi*6* 6(0.7-7*(m :)-0.8).。^2+(m(m :)-0.8).。^3).4.22));
end
cd(i)=cd0l(i)+k(i).*cl(i).^2;
D(i)=0.5.*cd(i).*1.4.*2116.2.*S.*M(i).^2;
end
If yes, you can this program without use for statement in a easy form.
m1tch
2 Comments
米奇·马特利(Mitch Martelli)
M=rand(1,18100);
with for : Elapsed time is 4.856499 seconds.
without for : Elapsed time is 0.037057 seconds.

Sign in to comment.


Sutae
Sutae 2012年12月2日
Thanks, but I was having gave an error occurs
This error is Undefined function or variable 'cl'. The first assignment to a local variable determines its class.
and cl &k cd0l else
In my opinion, (i) think using those things tell me if there is another way
Note that I will try to run this program(simulink in matlab use matlab function)
1 Comment
Walter Roberson
Walter Roberson 2012年12月2日
Pre-allocate "c1" and "cd01" and "k" and "cd" and "d"
还要对M为空的情况进行仔细检查您的完整例程。

Sign in to comment.

下载188bet金宝搏

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

开始狩猎!