Structure declaration in Matlab
7 ビュー (過去 30 日間)
古いコメントを表示
Hello, I have a matlab code piece having a structure defined. I want to define the structure wrap around to assign these data. The code is as below.
estruct.func_name = 'DATA_1';
estruct.variable(1).name = 't_user';
estruct.variable(1).req_dim = [901 2];
estruct.variable(1).var = data1;
estruct.variable(1).type = 'USR1';
estruct.variable(2).name = 'x_user';
estruct.variable(2).req_dim = [901 3; 901 4; 901 5; 1 3; 1 4; 1 5];
estruct.variable(2).var = data2;
estruct.variable(2).type = 'USR2';
: :
estruct.variable(10).name = 'p_user';
estruct.variable(10).req_dim = [1 4; 1 5];
estruct.variable(10).var = data10;
estruct.variable(10).type = 'USR10';
All i want is define a structure to accept/store this data. Can anyone help me out please
Srikanth
2 件のコメント
採用された回答
Friedrich
2012 年 8 月 27 日
編集済み: Friedrich
2012 年 8 月 27 日
Hi,
I dont have a MATLAB for testing at the moment but I guess the declaration should look like this:
estruct = struct('variable',{repmat(struct('name',[],'req_dim',[],'var',[],'type',[]),10,1)},'func_name','DATA_1')
I am not sure if the ML Coder likes repmat. If you get an error due repmat simply copy and past the inner struct definition 10 times.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Data Import and Analysis についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!