How to store results from loops and put them in matrice
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
I have this propostion:
clear all, clc
X=[0 1], Y=[0 1], Z=[0 1];
A=allcomb(X, Y,Z);
for p=1:10
R=[p.*A(:,1) A(:,2) A(:,3)];
R
end
I want that results of each iteration will be stored in matrice
1 Kommentar
Akzeptierte Antwort
Raj
am 28 Mai 2019
Bearbeitet: Raj
am 28 Mai 2019
Just pre define R as an empty array and use it inside the loop with suitable indexing. Something like this:
R=zeros(10,1); % Pre define R as zero array
for p=1:10
R(p,1)=[p.*A(:,1) A(:,2) A(:,3)];
R
end
At the end of Simulation, R will have all the elements you need.
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!