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!