MATLAB爱好者论坛-LabFans.com

MATLAB爱好者论坛-LabFans.com (https://www.labfans.com/bbs/index.php)
-   MATLAB论坛 (https://www.labfans.com/bbs/forumdisplay.php?f=6)
-   -   [MATLAB基础] matlab 输出结果的问题, (https://www.labfans.com/bbs/showthread.php?t=9728)

dengwei252 2009-09-21 21:20

matlab 输出结果的问题,
 
各位大虾:
在matlab的m文件中编辑循环的结构的时候,如果想输出循环的每一步结果,怎样写。
例子:
x0=2;
t=1;
i=0;
format long;
while abs(t)>(1e-10)
x1=x0-(x0^3-3*x0-1)/(3*x0^2-3);
i=i+1;
t=x1-x0;
x0=x1;
y=x1;
k=i;
end
想输出while循环中的每一补的x1和k值。
跪求

anbcjys 2009-09-22 18:17

回复: matlab 输出结果的问题,
 
x0=2;
t=1;
i=0;
format long;
while abs(t)>(1e-10)
x1=x0-(x0^3-3*x0-1)/(3*x0^2-3)
i=i+1;
t=x1-x0;
x0=x1;
y=x1;
k=i
end

花干儿 2009-09-22 19:33

回复: matlab 输出结果的问题,
 
给变量赋值时,末尾不打分号即可


所有时间均为北京时间。现在的时间是 06:31

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