make a continuous array

11 visualizaciones (últimos 30 días)
NIKHIL VALSAN KULANGARETH
NIKHIL VALSAN KULANGARETH el 9 de Abr. de 2018
Respondida: Rik el 9 de Abr. de 2018
My program is running an operation in loop(i=1,2,3,4....) and let the output for
1st value of i =[1 4 7]
2nd value of i =[3 7 4]
3rd value of I =[4 8 2]
I need an output in a row matrix which arranges these values as [1 4 7 3 7 4 4 8 2..........],ie, each output is made in a row, and so on
How can I implement this?

Respuestas (1)

Rik
Rik el 9 de Abr. de 2018
Pre-allocate one row (or preferably the entire matrix), and the use the colon to index the output:
output_mat=zeros(4,3);
for i=1:4
data=rand(1,3);%generate random values for this example
output_mat(i,:)=data;
end

Categorías

Más información sobre Creating and Concatenating Matrices 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