Undefined function or variable for struct variable

7 ビュー (過去 30 日間)
raha ahmadi
raha ahmadi 2021 年 2 月 7 日
コメント済み: raha ahmadi 2021 年 2 月 7 日
I have defined 'createModel' function but when I call struct variables from command window , for example
model.pmin(5) or unifrnd(pmin,pmax)
I get this error:
Undefined function or variable 'pmin'.
My code was attached. I have searched some similar questions but I cant solve yet. I really appreciate any help
Thanks in advance
Raha
function model=createModel ()
pmin=[553 782 502 781 608 461 553 699];
pmax=[2078 1907 1864 1562 1982 1437 1626 2138];
N=numel(pmin);
PL=10000;
a0=[7349 7737 6566 8530 9045 7502 6903 9809];
a1=[8 5 5 5 6 9 8 7];
a2=[-0.1817 -0.1010 -0.1395 -0.2037 -0.2740 -0.2296 -0.2540 -0.1358]*1e-4;
model.pmin=pmin;
model.pmax=pmax;
model.N=N;
model.PL=PL;
model.a0=a0;
model.a1=a1;
model.a2=a2;
end
  2 件のコメント
Stephen23
Stephen23 2021 年 2 月 7 日
It works for me:
S = createModel();
S.pmin(5)
ans = 608
function model=createModel ()
pmin=[553 782 502 781 608 461 553 699];
pmax=[2078 1907 1864 1562 1982 1437 1626 2138];
N=numel(pmin);
PL=10000;
a0=[7349 7737 6566 8530 9045 7502 6903 9809];
a1=[8 5 5 5 6 9 8 7];
a2=[-0.1817 -0.1010 -0.1395 -0.2037 -0.2740 -0.2296 -0.2540 -0.1358]*1e-4;
model.pmin=pmin;
model.pmax=pmax;
model.N=N;
model.PL=PL;
model.a0=a0;
model.a1=a1;
model.a2=a2;
end
raha ahmadi
raha ahmadi 2021 年 2 月 7 日
Thank you Stephen Cobeldick, I am really confused!

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

回答 (0 件)

カテゴリ

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