Info
この質問は閉じられています。 編集または回答するには再度開いてください。
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 ビュー (過去 30 日間)
古いコメントを表示
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 件のコメント
回答 (1 件)
Walter Roberson
2016 年 11 月 5 日
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 件のコメント
Walter Roberson
2016 年 11 月 9 日
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
この質問は閉じられています。
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!