Borrar filtros
Borrar filtros

how to print the result of for loops in two column

2 visualizaciones (últimos 30 días)
arash rad
arash rad el 20 de Ag. de 2022
Editada: dpb el 20 de Ag. de 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 comentarios
dpb
dpb el 20 de Ag. de 2022
Editada: Voss el 20 de Ag. de 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 el 20 de Ag. de 2022
Editada: dpb el 20 de Ag. de 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);

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by