MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [求助]高手帮忙看看吧 急 我初学 (https://www.labfans.com/bbs/showthread.php?t=5562)

xiaozheng33 2008-11-30 20:46

[求助]高手帮忙看看吧 急 我初学
 
初学MATLAB论文急用,M函数
求ac(k,1),ac(k,2) 两组值
function ac=concrete(k,i,j)
t1=60;t2=120;h1=60;h2=200;
for k=1:1:0.5*t1*(t2-t1)
for i=1:0.5*(t2-t1)
ac(k,1)=h2/t2*(i-0.5);
end
for j=1:t1
ac(k,2)=0.5*(h2-h1)+h1/t1*(j-0.5);
end
end
for k=0.5*t1*(t2-t1)+1:0.5*t1*(3*t2-t1)
for i=1:t1
ac(k,1)=h1/t1*(i-0.5)+0.5*(h2-h1);
end
for j=1:t2
ac(k,2)=h2/t2*(j-0.5);
end
end
for k=0.5*t1*(3*t2-t1):t1*(2*t2-t1)
for i=1:0.5*(t2-t1)
ac(k,1)=0.5*(h1+h2)+h2/t2*(i-0.5);
end
for j=1:t1
ac(k,2)=0.5*(h2-h1)+h1/t1*(j-0.5);
end
end
为什么运行结果是
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
179.1667 129.5000
这是我需要的这组值的最后一个啊?前面的怎么也是这个?

zhyanchao 2008-11-30 22:49

回复: [求助]高手帮忙看看吧 急 我初学
 
for i=1:0.5*(t2-t1)
ac(k,1)=0.5*(h1+h2)+h2/t2*(i-0.5);
end
在这次的for循环中ac(k,1)的最终值是在i=0.5*(t2-t1)=60时获得的。即
ac(k,1)恒等于0.5*(h1+h2)+h2/t2*(60-0.5)=179.1667.
for j=1:t1
ac(k,2)=0.5*(h2-h1)+h1/t1*(j-0.5);
end
在这次的for循环中ac(k,2)的最终值是在j=t1=60时获得的。即
ac(k,1)恒等于0.5*(h2-h1)+h1/t1*(60-0.5)=129.5.
综上原因,得出你现在的结果。


所有时间均为北京时间。现在的时间是 11:08

Powered by vBulletin
版权所有 ©2000 - 2025,Jelsoft Enterprises Ltd.