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 日間)
kiranpreet kaur
kiranpreet kaur 2016 年 11 月 5 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
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...........

回答 (1 件)

Walter Roberson
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 件のコメント
kiranpreet kaur
kiranpreet kaur 2016 年 11 月 9 日
yes sir i expecting that generate mobility routine to do differently with every node that is present in x 11 struct
Walter Roberson
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!

Translated by