首页 > 解决方案 > Matlab中的输出方向(水平到垂直)

问题描述

以下 Matlab 代码有效,但我希望输出采用列格式而不是行格式。最终,我希望 Matlab 最后输出一个表格。这将是变量 abn dt it(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.

谢谢。毫米

标签: matlaboutput

解决方案


推荐阅读