how to print the result of for loops in two column

2 次查看(过去 30 天)
Hi
I have these two for loops and i want to print them in two column but it prints in one column how can I change my code that i have two column
qd(1,:) = Ftu(1).*qu(1)
for i = 2:10
qd(i,:) = (1 - Ftu(i))*qd(i - 1,:) + Ftu(i).*qu(i);
if i == 10
for k = 11:20
qd(k,:) = (1 - Ftu(k))*qd(10,:) + Ftu(k).*qu(k);
end
end
end
and it is my answer
  3 个评论
dpb
dpb 2022-8-20
编辑:Voss 2022-8-20
Although we can't tell, maybe qu is a 2-column array and just missing the colon there???
qd(1,:) = Ftu(1).*qu(1,:);
MIGHT do the trick, but as Walter says, we can't know, can only guess, ...
dpb
dpb 2022-8-20
编辑:dpb 2022-8-20
The above code (without addressing the two-column issue) could be written with MATLAB vector addressing as
qd(1,:) = Ftu(1).*qu(1)
i=(2:10);
qd(i,:) = (1 - Ftu(i)).*qd(i-1,:) + Ftu(i).*qu(i);
k=(11:20);
qd(k,:) = (1 - Ftu(k)).*qd(10,:) + Ftu(k).*qu(k);

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

标签

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by