フィルターのクリア

save data in a array

1 回表示 (過去 30 日間)
elisa ewin
elisa ewin 2017 年 3 月 29 日
回答済み: Rik 2017 年 3 月 29 日
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?

採用された回答

Rik
Rik 2017 年 3 月 29 日
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);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by