Build arrays under the for loop

3 visualizzazioni (ultimi 30 giorni)
Mohamed Zied
Mohamed Zied il 13 Feb 2023
Commentato: Mohamed Zied il 14 Feb 2023
Hi;
for i=1:10
R"i"= nonzeros(D(i,:));
end
I want to create arrays under the for loop. The arrays wont have the same size. For each increment, the name of the array should be R + the increment number (R1, R2, R3 ....).
The desired result is 10 vectors R1 to R10.
Any hints to do it ?
Thank you in advance

Risposte (1)

KSSV
KSSV il 13 Feb 2023
Modificato: KSSV il 13 Feb 2023
R = cell(10,1) ;
for i=1:10
R{i}= nonzeros(D(i,:));
end
You can access by R{1},R{2},...R{10}. R is a cell array. You need not to name it as R1, R2...R10.
  1 Commento
Mohamed Zied
Mohamed Zied il 14 Feb 2023
The aim is to use this arrays with distributionFitter. I build a cell array, but it couldn't be used with distributionFitter. That's why I am looking for another solution.

Accedi per commentare.

Prodotti


Release

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by