How to store vectores which have different lengts? (in a loop)

1 visualizzazione (ultimi 30 giorni)
This doesnt work because every tupple have differents lengths :
for i=2:5
ar(i,:)=ones(1,q(i)-q(i-1)+2);
end
q is a random generated vector here.
What I intended to do is:
ar(2,:)=ones(1,q(2)-q(1)+2)
ar(3,:)=ones(1,q(3)-q(2)+2)
.
.
.

Risposta accettata

madhan ravi
madhan ravi il 13 Dic 2018
Store it as cell like below:
ar=cell(1,4);
for i=2:5
ar{i-1}=ones(1,q(i)-q(i-1)+2);
end
celldisp(ar)

Più risposte (0)

Categorie

Scopri di più su Dynamic System Models in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by