Undefined function or variable for struct variable

7 次查看(过去 30 天)
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

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Structures 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by