MATLAB Answers

Error :Nonscalar arrays of function handles are not allowed; use cell arrays instead.

1 ビュー (過去 30 日間)
Shimon Katzman
Shimon Katzman 2019 年 11 月 30 日
Answered: Star Strider 2019 年 11 月 30 日
Hi everyone,
trying to plot the graph like in the picture but got Error using this code:
Es=200000; %Mpa
Esh=8500; %Mpa
fy=500; %Mpa
fsu=750; %Mpa
epssh=0.009;
epssu=0.075;
P=Esh*((epssu-epssh)/(fsu-fy));
epsy=fy/Es;
epscmv = linspace(0.1, 10, 500)*1E-3;
for i=1:numel(epscmv);
epscm = epscmv(i);
sigmaSteel(i)=@(epscm) Es*epscm .* (epscm<=epsy) + fy .* (epscm>epsy & epscm<=epssh) + fsu+(fy-fsu)*abs((epssu-epscm)./(epssu-epssh))^(1/P) .* (epscm>epssh & epscm<=epssu) + 0 .* (epscm>epsu);
end
plot(epscmv, sigmaSteel)
grid on
Thank you very much

  3 件のコメント

Stephen Cobeldick
Stephen Cobeldick 2019 年 11 月 30 日
"trying to plot the graph like in the picture..."
Then why are you trying to create an array of function handles?
Shimon Katzman
Shimon Katzman 2019 年 11 月 30 日
Dear Sthephen.
1.Im new to Matlab.
2.Later I will need to use this function, this is just the beggining of the code that i am writing.
Shimon Katzman
Shimon Katzman 2019 年 11 月 30 日
Es=200000; %Mpa
Esh=8500; %Mpa
fy=500; %Mpa
fsu=750; %Mpa
epssh=0.009;
epssu=0.075;
P=Esh*((epssu-epssh)/(fsu-fy));
epsy=fy/Es;
epscmv = linspace(0, 10, 5000)*1E-3;
for i=1:numel(epscmv);
epscm = epscmv(i);
sigmaSteel(i)= Es*epscm .* (epscm<=epsy) +fy .* (epscm>epsy & epscm<=epssh) + fsu+(fy-fsu)*abs((epssu-epscm)./(epssu-epssh))^(1/P) .* (epscm>epssh & epscm<=epssu) + 0 .* (epscm>epssu);
end
plot(epscmv, sigmaSteel)
grid on

サインイン to comment.

採用された回答

Star Strider
Star Strider 2019 年 11 月 30 日
The loop is not necessary.
This required a few corrections (a typographical error and to vectorise the exponentiation), and now appears to work:
Es=200000; %Mpa
Esh=8500; %Mpa
fy=500; %Mpa
fsu=750; %Mpa
epssh=0.009;
epssu=0.075;
P=Esh*((epssu-epssh)/(fsu-fy));
epsy=fy/Es;
epscmv = linspace(0.1, 10, 500)*1E-3;
sigmaSteel=@(epscm) Es*epscm .* (epscm<=epsy) + fy .* (epscm>epsy & epscm<=epssh) + fsu+(fy-fsu)*abs((epssu-epscm)./(epssu-epssh)).^(1/P) .* (epscm>epssh & epscm<=epssu) + 0 .* (epscm>epssu);
figure
plot(epscmv, sigmaSteel(epscmv))
grid on
It does not exactly reproduce the plot in the 1.jpg attachment, although it appears to be reasonably close.

  0 件のコメント

サインイン to comment.

More Answers (0)

サインイン してこの質問に回答します。


Translated by