how to print the result of for loops in two column

1 Ansicht (letzte 30 Tage)
arash rad
arash rad am 20 Aug. 2022
Bearbeitet: dpb am 20 Aug. 2022
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 Kommentare
dpb
dpb am 20 Aug. 2022
Bearbeitet: Voss am 20 Aug. 2022
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 am 20 Aug. 2022
Bearbeitet: dpb am 20 Aug. 2022
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);

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by