structure to array

1 visualización (últimos 30 días)
Trader
Trader el 2 de Abr. de 2012
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!

Respuestas (1)

Oleg Komarov
Oleg Komarov el 2 de Abr. de 2012
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.

Categorías

Más información sobre Structures 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