Make a table from a loop

9 visualizaciones (últimos 30 días)
Ahmad El-Kassem
Ahmad El-Kassem el 26 de Abr. de 2017
Comentada: Deepmala Ray el 2 de En. de 2022
Hello
I am trying to make a table that looks like this
_____x_____y____z
1
2
3
4
but i get 3 results for every loop, and i therefore dont know how to put them together

Respuesta aceptada

KL
KL el 26 de Abr. de 2017
Editada: KL el 26 de Abr. de 2017
Hey, you need to save the values inside for loop. You can do it either by creating a bigger x matrix with n rows and 3 columns so you can finally use table(x) to create a table or you can add rows to a predefined table inside the for loop.
T = table;
for n = 1:10
x = P*x+q;
x_t = table(x(1),x(2),x(3));
T = [T; x_t];
end
T.Properties.VariableNames = {'x' 'y' 'z'};
  3 comentarios
Sunil Verma
Sunil Verma el 9 de Dic. de 2020
Editada: Sunil Verma el 9 de Dic. de 2020
Thanks KL sir, I got solution from your code segment. I am trying since two days. finally I reach on solution. thankyou very much
Deepmala Ray
Deepmala Ray el 2 de En. de 2022
thank you so much for this section of code....it helped alot

Iniciar sesión para comentar.

Más respuestas (1)

safi khan
safi khan el 4 de En. de 2020
To Make a Table in MATLAB on for Loop.
Here is the code of Tabe 5.
for a= 1:10
b=a*5
end

Categorías

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

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by