Borrar filtros
Borrar filtros

save data in a array

1 visualización (últimos 30 días)
elisa ewin
elisa ewin el 29 de Mzo. de 2017
Respondida: Rik el 29 de Mzo. de 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?

Respuesta aceptada

Rik
Rik el 29 de Mzo. de 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);

Más respuestas (0)

Categorías

Más información sobre Matrix Indexing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by