how to get struct array field as a vector?
25 ビュー (過去 30 日間)
古いコメントを表示
I have a struct array, and a field like data.age and I want to get the ages as a vector v for which I can write for example : v(v>18), because data.age(data.age>18) gives me an error message.
1 件のコメント
採用された回答
その他の回答 (2 件)
Walter Roberson
2015 年 10 月 12 日
v = [data.age];
data(v>18)
Or more compactly,
data([data.age]>18)
Tin Aye Chit Chit
2019 年 5 月 15 日
Please check the code, that code can't give me the answer I want.
for i = 1:1:n
V=index{i};
for j = 1:1:size(V,2)
S{i,j}.e = nodeArch.node(V(1,j)).energy;
S{i,j}.t = nodeArch.node(V(1,j)).type;
S{i,j}.g = nodeArch.node(V(1,j)).G;
end
end
The S have more column than V. What is wrong in that code?
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Structures についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!