帮忙检查下程序,有个循环不能执行
%function Mredsim=n_Mm(Jredsim)%Set initial "gemesste Strom"
Im = [151.0348139.0837119.3383105.828390.759585.563379.8475 78.288782.6188...
82.4456 82.4456 83.6581 85.909785.9097115.1814 139.0837 143.4138 148.0903...
133.7143117.4330107.9068106.0015 116.047443.301346.7654344.3317 146.5315...
146.5315 80.5404 80.540480.713680.7136 137.3516132.3287 90.413175.1710...
72.5729 75.8638 78.2887 78.2887 161.2539164.3716162.9860138.5641 144.7994...
158.1362166.6233166.7965 213.7351 192.0844140.6425108.080090.2398 80.7136...
82.0992 91.4523 103.5766 105.6551 105.8283104.4427111.890551.9615 49.1902...
403.0482 400.4501161.7735161.7735106.8675188.9667229.8431231.4020 231.4020...
177.7084156.9238142.3746 25.9808 69.2820402.5286401.3162333.9394 321.4686...
310.7299258.5952200.9179200.9179124.3612109.812095.4360 91.4523 91.6255...
104.2695122.9756126.2665150.8616167.6625169.5678153.1133139.6033 127.3057...
125.7469112.0637126.0933183.5974200.9179213.0422251.6670216.3331216.3331...
119.5115112.0637109.4656110.3316116.7402115.8742106.5211103.9230 96.4752...
97.5145 99.0733104.0963106.1747110.6780103.9230100.4589 90.7595 87.8150...
86.4293 86.0829 86.2561 86.4293 86.4293 86.2561 85.2169 79.8475 79.8475...
77.7691 78.9815 80.8868 82.6188 82.4456 81.5796 78.9815 78.8083 80.7136...
81.4064 81.2332 80.8868 80.7136 79.8475 80.1940 82.4456 82.7920 83.4848...
85.5633 87.6418 90.7595 93.3575 93.8772 93.5307 93.0111 92.4915 91.7987...
91.6255 89.5470 89.7202 89.8934 89.8934 89.7202 89.7202 89.7202 89.5470...
89.3738 88.8542 88.8542 89.0274 89.3738 92.6647 92.1451 91.4523 90.7595...
87.2954 87.1222 87.1222 87.2954 87.4686 87.6418 87.6418 87.9882 87.9882...
88.5078 88.8542 89.2006 89.0274 89.0274 99.2465111.8905112.5833 122.4560...
122.2828111.8905109.6388 95.4360 86.0829 84.1777 83.4848 84.0045 84.8705...
92.1451 91.2791 91.1059 91.9719104.2695130.9430168.3553170.4338183.2510...
191.9112260.0000291.5042291.5042236.4249198.4930198.4930122.4560 87.2954...
83.1384 81.9260 92.8379107.3872115.7010 111.7173101.1518 89.5470 86.4293...
81.2332 80.8868 80.8868 81.5796 93.5307 95.4360103.9230 106.0015107.3872...
113.6225116.0474130.4234165.4109177.8816194.1629223.2613223.7810207.1533...
204.3820170.2606150.5152138.9105127.3057114.3154100.1125 97.3413 90.9327...
92.4915104.4427 138.5641152.5937154.6721159.3487141.5086123.6684124.5345 ...
170.9534188.7935204.7284213.3887183.2510148.2635 94.0504 79.6743 73.9586...
79.3279 93.1843 91.9719 91.4523 90.2398 81.7528 80.3672 65.8179 25.9808...
29.4449273.1444308.3050283.5367 69.4552 74.8246 74.6514 79.5011 83.3116...
85.3901 81.9260 73.7854 72.2265 72.2265 73.4390 75.1710 77.5959 77.4227...
75.5174 74.1318 73.6122 73.2657 73.2657 73.9586 74.3050 74.8246 74.6514...
74.4782 73.9586 73.9586 73.9586 73.9586 73.9586 74.1318 74.1318 74.1318...
74.1318 74.1318 74.1318];
%Drehnzahl rechnen
S=sqrt(65.02759421^2-4*(-0.02463815532)*(-42058.38932-Im));
nm=(-65.02759421-S)./(2*(-0.02463815532));
%Differenzial Gleichung rechnen
Jred=195;
Jredsim=input('enter the number of Jredsim : ');
tm=1:326;
dt=1;
%Mit formel Mred und Mredsim ausrechne
Mm= polyval(,nm);
Mred=Mm(1:326)-(abs(diff(nm))*2*pi*Jred/60);
%Mredsim ausrechnen
n_e=zeros(1,size(nm(1:326),2));
Mm_e=zeros(1,size(nm(1:326),2));
for i=1:size(nm(1:326),2)
if i==1
n0=nm(i);
Mm_e(i)=polyval(,n0);
sn=(Mm_e(i)-Mred(i))*dt/(2*pi*Jredsim);
n_e(i)=n0+sn;
else
Mm_e(i)=polyval(,n_e(i-1));
sn=(Mm_e(i)-Mred(i))*dt/(2*pi*Jredsim);
n_e(i)=nm(i)+sn;
end
end
%Plot Motormoment-Mm,drehnzahl-n,reduziere Motormoment-Mred und reduziere simulink Motormoment-Mred
=plotyy(tm,,tm,);
ylim(AX(1),[-1000 1550]);
ylim(AX(2),);
%xlim(AX(1),);
%xlim(AX(2),);
set(AX,'XTick',);
set(AX(1),'YTick',[-1000:85:1550]);
set(AX(2),'YTick',);
set(get(AX(1),'ylabel'),'String','Mm (t)','color','b','FontSize',14);
set(get(AX(2),'ylabel'),'String','nm(t)','color','r','FontSize',14);
set(H1(1),'LineStyle','-','color','b');
set(H1(2),'LineStyle','-','color','k');
set(H2(1),'LineStyle','-','color','r');
set(H2(2),'LineStyle','-','color','g');
box off;
title('Momentreduziert und Drehzahl','FontSize',16);
xlabel('t ','FontSize',14);
legend(H1,{'Mm','Mred(t)'},2)
legend(H2,{'nm','nredsim(t)'},1)
grid on;
在这个程序中的for和if循环语句不起作用,这是为什么?无论Jredsim是什么值,所显示出来的图都是一样的
哪位大大 能帮忙,当Jredsim输入不同的值的时候所得到的n_e应该是不同于nm的,而且很明显,但这个程序显示的不是这样
[ 本帖最后由 tianyi11911 于 2009-3-11 15:37 编辑 ] LZ的程序真的太长了, 可能很少人愿意看!
"无论Jredsim是什么值,所显示出来的图都是一样的!", 那很正常嘛!
n_e与nm基本上差个sn (n_e(i)=nm(i)+sn), 而sn=(Mm_e(i)-Mred(i))*dt/(2*pi*Jredsim), 当Mm_e与Mred很接近且Jredsim值较大时, sn非常小, 与nm差好几量级!
LZ可以Jredsim取10及100, 并在程序增加两行比较便知
figure; plotyy(tm,Mm(1:326),tm,Mred)
figure; plotyy(tm,nm(1:326),tm,n_e)
[ 本帖最后由 ChaChing 于 2009-3-12 16:33 编辑 ] 谢谢主任,主任真是太好了,我的问题基本都是您给出的答复,非常感谢。
这个问题我用Excel做了一下 ,还是有很大差距的,但在matlab里差距就不大,所以就搞不明白了。
我再用您给的句子对比一下吧。谢谢
[ 本帖最后由 tianyi11911 于 2009-3-13 17:54 编辑 ]
页:
[1]