how to print the result of for loops in two column

1 回表示 (過去 30 日間)
arash rad
arash rad 2022 年 8 月 20 日
編集済み: dpb 2022 年 8 月 20 日
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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by