Vectorize a for loop and if-else statement
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello. Can anybody help me to vectorize:
L=1;
A=0;
for L=1:100
for i=1:25
A=A+1;
if E(L).a == N(i).a
HD(A,L)=myfunction(T0,M0,T(i).a,M(i).a);
else
HD(A,L)=0;
end
A=A+1;
if E(L).a == N(i).b
HD(A,L)=myfunction(T0,M0,T(i).b,M(i).b);
else
HD(A,L)=0;
end
end
end
where E,N,T,M are struct. T0 and M0 are 128x720 double. Thanks
8 Kommentare
Ced
am 10 Mär. 2016
Have you seen this?
It's not exactly what you asked, but why write something yourself if it already exists? Unless it's a personal exercise, that's always a good reason.
Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!