How to pass inputs to simulink for nested structures with array of structures

5 ビュー (過去 30 日間)
CHV
CHV 2019 年 5 月 20 日
コメント済み: Murugan C 2019 年 5 月 21 日
Hello,
I need to test the simulink model in Matlab 2016b which is having the structure type as below. I have already created the bus in the simulink for that structure.
Now I need to know how to create the inputs and pass to simulink block ?
a = struct ('b',1,'c',2,'d',struct('f',{3,4,5},'g',{6,7,8},'h',{struct('i',{9,10,11},'j',{12,13,14}),struct('i',{15,16,17},'j',{18,19,20})}))

回答 (1 件)

Murugan C
Murugan C 2019 年 5 月 20 日
Hi
You should create structure as like below.
a = struct ('b',1,'c',2,'d',struct('f',{3,4,5},'g',{6,7,8},'h', ...
{struct('i',{9,10,11},'j',{12,13,14}),struct('i',{15,16,17},'j',{18,19,20}), ...
struct('i',{21,22,23},'j',{24,25,26})}));
struc12.png
if you want to acess "h" from the above structure. we have to use as like. "a.d(1).h". Because "h" has three rows. the output would be.
struc1.png
  2 件のコメント
CHV
CHV 2019 年 5 月 20 日
Hi Murugan,
I would like to know how to pass that structure as input to simulink ? Could you please help me on this.
Murugan C
Murugan C 2019 年 5 月 21 日
We have to create a structure with time series and signals. Then only we can this structure as input to the "From Workspace" simulink block.
For ex1.
% create struct with time series.
A.time = 0:10;
A.time = A.time';
A.signals.values = 1:11;
A.signals.values = A.signals.values';
A.signals.dimenstions = 1;
from_Work.JPG
For ex2.
We can use a "constant" block also from simulink.
% create struct with using parameter.
Input1 = Simulink.Parameter;
Input1.Value = 1;
Input1.DataType = 'uint8';
Input1.Min = 0;
Input1.Max = 250;
Input1.RTWInfo.StorageClass = 'Custom';
Input1.RTWInfo.CustomStorageClass = 'Define';
const.JPG
As per my understanding, we can't use a structure what you have given.
a = struct ('b',1,'c',2,'d',struct('f',{3,4,5},'g',{6,7,8},'h', ...
{struct('i',{9,10,11},'j',{12,13,14}),struct('i',{15,16,17},'j',{18,19,20}), ...
struct('i',{21,22,23},'j',{24,25,26})}));
If I am worng, Please correct me.
Thanks in Advance !!!

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeStructures についてさらに検索

タグ

製品

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by