replacing the for loops

L=(length(time)-1);
for q=1:numPT
for h=1:L
x(q,h)=SortDate(q,5);
y(q,h)=SortDate(q,6);
c(q,h)=SortDate(q,4);
end
end

1 Commento

what if its changed to this?
L=(length(time)-1);
for q=1:numPT
for h=1:L
x(q,h)=SortDate{q+numPT*(h-1),6};
y(q,h)=SortDate{q+numPT*(h-1),7};
c(q,h)=SortDate{q+numPT*(h-1),5};
end
end

Accedi per commentare.

 Risposta accettata

Andrei Bobrov
Andrei Bobrov il 21 Lug 2017
Modificato: Andrei Bobrov il 21 Lug 2017
cxy = permute(repmat(SortDate(q,4:6),1,1,L),[1 3 2]);
here cxy your arrays c,x and y as cxy = cat(3,c,x,y)

2 Commenti

pg
pg il 21 Lug 2017
It works Thanks so much !!
what if the question is changed to this how can I replace the for loops?
L=(length(time)-1);
for q=1:numPT
for h=1:L
x(q,h)=SortDate{q+numPT*(h-1),6};
y(q,h)=SortDate{q+numPT*(h-1),7};
c(q,h)=SortDate{q+numPT*(h-1),5};
end
end

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su Loops and Conditional Statements in Centro assistenza e File Exchange

Richiesto:

pg
il 21 Lug 2017

Commentato:

pg
il 9 Ago 2017

Community Treasure Hunt

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

Start Hunting!

Translated by