Info
This question is closed. Reopen it to edit or answer.
i want to made struct <1*11> of s_input for 10 number of nodes(NB_NODES) without pre defining NB_NODES outside of the struct because i have to use this NB_NODES in other functions by giving its reference..
4 views (last 30 days)
Show older comments
s_input = struct('V_POSITION_X_INTERVAL',[0 30],...%(m)
'V_POSITION_Y_INTERVAL',[0 30],...%(m)
'V_SPEED_INTERVAL',[0.2 2.2],...%(m/s)
'V_PAUSE_INTERVAL',[0 1],...%pause time (s)
'V_WALK_INTERVAL',[2.00 6.00],...%walk time (s)
'V_DIRECTION_INTERVAL',[-180 180],...%(degrees)
'SIMULATION_TIME',500,...%(s)
'NB_NODES',10,.....
'energy',E);
plz help me that how can i made s_input struct of 1*11 for 10 NB_NODES,but i does not want to define NB_NODES outside the struct...........
0 Comments
Answers (1)
Walter Roberson
on 5 Nov 2016
I am not sure what you are trying to do, but perhaps
s_input = struct('V_POSITION_X_INTERVAL',[0 30],...%(m)
'V_POSITION_Y_INTERVAL',[0 30],...%(m)
'V_SPEED_INTERVAL',[0.2 2.2],...%(m/s)
'V_PAUSE_INTERVAL',[0 1],...%pause time (s)
'V_WALK_INTERVAL',[2.00 6.00],...%walk time (s)
'V_DIRECTION_INTERVAL',[-180 180],...%(degrees)
'SIMULATION_TIME',500,...%(s)
'NB_NODES',repmat({10},1,11),.....
'energy',E);
?
Or perhaps
s_input = struct('V_POSITION_X_INTERVAL',[0 30],...%(m)
'V_POSITION_Y_INTERVAL',[0 30],...%(m)
'V_SPEED_INTERVAL',[0.2 2.2],...%(m/s)
'V_PAUSE_INTERVAL',[0 1],...%pause time (s)
'V_WALK_INTERVAL',[2.00 6.00],...%walk time (s)
'V_DIRECTION_INTERVAL',[-180 180],...%(degrees)
'SIMULATION_TIME',500,...%(s)
'NB_NODES',10,.....
'energy',E);
s_input = repmat(s_input, 1, s_input.NB_NODES+1);
6 Comments
Walter Roberson
on 9 Nov 2016
Why should it do any differently? You are sending in identical structure members.
In any case if you want the generation routine to work on structure arrays then you need program it to do so. That might just involve one more outer level of looping. It depends on whether the members interact. Why not just loop calling the generation routine? You can do that with arrayfun
This question is closed.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!