Matlab

时间:2018-06-16 11:12:04

标签: matlab output

以下Matlab代码可以工作,但我希望输出采用列格式而不是行格式。最后,我希望Matlab最后输出一个表格。它将是变量的迭代历史a b n dt i t(i)y(i)

怎么办?

% Euler Method dy/dt=f(t,y)=sin(t^2)*sqrt(y)
f=@(t,y)(sin(t^2)*sqrt(y))
t(1)=1;
y(1)=1;
a=1;
b=3;
n=10;
dt=(b-a)/n;

for i=1:1:n
y(i+1)=y(i)+f(t(i),y(i))
t(i+1)=t(i)+dt;
end

I want to transpose the output (horizontal to vertical columns of t and y                        
side by side as opposed to a long column of t concatenated by y below.

[t y]' does the latter.

感谢。 MM

0 个答案:

没有答案