Clear Filters
Clear Filters

how to print the result of for loops in two column

2 views (last 30 days)
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 Comments
dpb
dpb on 20 Aug 2022
Edited: Voss on 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 on 20 Aug 2022
Edited: dpb on 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);

Sign in to comment.

Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!