Effacer les filtres
Effacer les filtres

save data in a array

1 vue (au cours des 30 derniers jours)
elisa ewin
elisa ewin le 29 Mar 2017
Réponse apportée : Rik le 29 Mar 2017
Hi, I have a problem: I have create this code
for j=1:size(user(4).data(5).idx,1)
if (user(4).data(5).idx(j,1)~=0)
a=Cluster_USERS{4,1}(user(4).data(5).idx(j,1),4)
end
end
now I have:
a =
7
a =
7
a =
7
a =
0
I want a=[ 7 7 7 0], how can I modified the code?

Réponse acceptée

Rik
Rik le 29 Mar 2017
You forgot a semicolon (the ; sign) to suppress output and a was overwritten each loop itteration.
There is a method to use logical indexing instead of a loop. The code below should work.
a=Cluster_USERS{4,1}(user(4).data(5).idx(:,1)~=0,4);

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by