永发信息网

如何让matlab的数据边计算边存入磁盘,或者导入excel

答案:2  悬赏:0  手机版
解决时间 2021-03-01 02:49
  • 提问者网友:情歌越听越心酸
  • 2021-02-28 11:16
我在做matlab时,由于数据多,不能在command window中全部看到,只能看到后一部分,在workspace中也只有最终结果。所以我想让它边计算边存盘。这是我的后一部分:
w=2500.000000 t=0.500000 b=0.500000 a=210.000000 F=684.031908
w=2500.000000 t=0.500000 b=0.500000 a=215.000000 F=2063.094235
w=2500.000000 t=0.500000 b=0.500000 a=220.000000 F=292.036371
w=2500.000000 t=0.500000 b=0.500000 a=225.000000 F=1885.062505
w=2500.000000 t=0.500000 b=0.500000 a=230.000000 F=982.794622
w=2500.000000 t=0.500000 b=0.500000 a=235.000000 F=903.903072
w=2500.000000 t=0.500000 b=0.500000 a=240.000000 F=1938.562261
w=2500.000000 t=0.500000 b=0.500000 a=245.000000 F=281.147675
w=2500.000000 t=0.500000 b=0.500000 a=250.000000 F=2027.867268
w=2500.000000 t=0.500000 b=0.500000 a=255.000000 F=754.036495
w=2500.000000 t=0.500000 b=0.500000 a=260.000000 F=1144.987172
w=2500.000000 t=0.500000 b=0.500000 a=265.000000 F=1762.746780
w=2500.000000 t=0.500000 b=0.500000 a=270.000000 F=335.107104
w=2500.000000 t=0.500000 b=0.500000 a=275.000000 F=2113.131108
w=2500.000000 t=0.500000 b=0.500000 a=280.000000 F=556.992145
w=2500.000000 t=0.500000 b=0.500000 a=285.000000 F=1390.391939
w=2500.000000 t=0.500000 b=0.500000 a=290.000000 F=1547.966823
w=2500.000000 t=0.500000 b=0.500000 a=295.000000 F=450.133832
w=2500.000000 t=0.500000 b=0.500000 a=300.000000 F=2134.879761
w=2500.000000 t=0.500000 b=0.500000 a=305.000000 F=405.468066
w=2500.000000 t=0.500000 b=0.500000 a=310.000000 F=1622.922367
w=2500.000000 t=0.500000 b=0.500000 a=315.000000 F=1309.271578
w=2500.000000 t=0.500000 b=0.500000 a=320.000000 F=1309.271578
w=2500.000000 t=0.500000 b=0.500000 a=325.000000 F=1309.271578
w=2500.000000 t=0.500000 b=0.500000 a=330.000000 F=1309.271578
w=2500.000000 t=0.500000 b=0.500000 a=335.000000 F=1309.271578
w=2500.000000 t=0.500000 b=0.500000 a=340.000000 F=1309.271578
w=2500.000000 t=0.500000 b=0.500000 a=345.000000 F=1309.271578
w=2500.000000 t=0.500000 b=0.500000 a=350.000000 F=1309.271578
w=2500.000000 t=0.500000 b=0.500000 a=355.000000 F=1309.271578
w=2500.000000 t=0.500000 b=0.500000 a=360.000000 F=1309.27157
PI=3.14;
Cd=0.6;
z=1.297;
for w=1000:100:2500
for t=0.1:0.05:0.5
for b=0.2:0.05:0.5
for a=0:5:360
a1=a*PI/180;
r=0.707*b+0.02;
w1=2*PI*w/60;
if (a1>-asin(0.5*b/r))&(a1<asin(0.5*b/r))
F= t*Cd*z*((w1)^2)*r*(sin(a))*(4*(r*sin(a))^2+3*b^2)/6;
end
if (a1>=asin(0.5*b/r))&(a1<=(2*PI-asin(0.5*b/r)))
F=Cd*z*((w1)^2)*b*t*((r*sin(a))^2+(b^2)/12)
end
fprintf('w=%f \t t=%f \t b=%f \t a=%f \t F=%f \n',w,t,b,a,F)
end
end
end
end
我想把每一个变量都存起来,但是这个不行。
最佳答案
  • 五星知识达人网友:我住北渡口
  • 2021-02-28 11:27
跟数据无关,要看你的代码。
看你这里这样,估计是用disp之类的输出

你用fpintf函数可以实现,
具体的可以查看help fprintf
跟C语言差不多。

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
PI=3.14;
Cd=0.6;
z=1.297;
fid=fopen('zdData.txt','w');
for w=1000:100:2500
for t=0.1:0.05:0.5
for b=0.2:0.05:0.5
for a=0:5:360
a1=a*PI/180;
r=0.707*b+0.02;
w1=2*PI*w/60;
if (a1>-asin(0.5*b/r))&(a1<asin(0.5*b/r))
F= t*Cd*z*((w1)^2)*r*(sin(a))*(4*(r*sin(a))^2+3*b^2)/6;
end
if (a1>=asin(0.5*b/r))&(a1<=(2*PI-asin(0.5*b/r)))
F=Cd*z*((w1)^2)*b*t*((r*sin(a))^2+(b^2)/12);
end
fprintf('w=%f \t t=%f \t b=%f \t a=%f \t F=%f \n',w,t,b,a,F)
fprintf(fid,'w=%f \t t=%f \t b=%f \t a=%f \t F=%f \n',w,t,b,a,F);

end
end
end
end

fclose(fid);
全部回答
  • 1楼网友:酒者煙囻
  • 2021-02-28 11:40
你好! 用dlmwrite函数。注意参数选append. 希望对你有所帮助,望采纳。
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯