structure to array
1 回表示 (過去 30 日間)
古いコメントを表示
I'm looking to write values stored in an structure to an array like this:
p_start = 20;
p_end = 400;
p_diff = p_end - p_start;
x = 1;
s.test1 = zeros(p_diff,1);
s.test2 = zeros(p_diff,1);
s.test3 = cell(p_diff,1);
t_array = cell(p_diff,3);
for i=p_start:1:p_end
t_array(x,:) = {s.test1(i) s.test2(i) s.test3.(i)};
x = x+1;
end
is it possible to fill t_array without having to go through a loop?
Thanks for your help!
0 件のコメント
回答 (1 件)
Oleg Komarov
2012 年 4 月 2 日
In this case no, and you have to use:
for i = 1:p_diff
t_array(i,:) = {s.test1(i) s.test2(i) s.test3{i}};
end
If you try to describe why are you creating test1 and test2 etc... and what you wanna do next we can try to come up with loopless solution.
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!