Undefined function or variable for struct variable

3 visualizaciones (últimos 30 días)
raha ahmadi
raha ahmadi el 7 de Feb. de 2021
Comentada: raha ahmadi el 7 de Feb. de 2021
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 comentarios
Stephen23
Stephen23 el 7 de Feb. de 2021
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 el 7 de Feb. de 2021
Thank you Stephen Cobeldick, I am really confused!

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Structures en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by