用m文件运行一个simulink没问题,放入函数中就无法运行。
Show older comments
function f_ndim %若无,可以运行
m=16;
Ic=8;
c1=10;
c2=5;
a1=0.3;
a2=0.3;
k1=100;
k2=50;
f1=300;
f2=30;
c11=c2*a2-c1*a1;
%set_param('untitled25/Gain','Gain','c11');
sim('untitled25');
mm1=(simout(1:1000:20000))';
mm2=(simout1(1:1000:20000))';
M1=[0 1.3517 0.74987 1.0452 1.0086 0.9438 0.95586 0.90908 0.99553 0.97777 0.98455 0.93354 0.94574 0.96121 0.98627 0.97212 0.95277 0.94453 0.96087 0.97546];
M2=[0 -0.73396 -0.37299 0.058072 0.2085 -0.11548 -0.46445 -0.38843 -0.067179 0.10622 -0.079026 -0.33412 -0.35452 -0.13896 0.014727 -0.066035 -0.25477 -0.3076 -0.18061 -0.050495];
%M=[0 0.0477 0.0026 -0.0008 -0.0480 0.0015 0.0112 0.0237 -0.0123 -0.0213 -0.0139 0.0109 0.0126 -0.0022 -0.0170 -0.0117 0.0031 0.0093 -0.0001 -0.0112];
z=sum((100.*(mm1-M1)).^2+(100.*(mm2-M2)).^2)
Accepted Answer
More Answers (0)
Categories
Find more on Electrical Block Libraries in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!