Error - Vectors must be the same length

1 回表示 (過去 30 日間)
Shimon Katzman
Shimon Katzman 2019 年 11 月 24 日
コメント済み: Star Strider 2019 年 11 月 26 日
Hi everyone,
This is very wierd.
I entered this code to plot a (epscmv, cdivd) graph and there are two problems:
1) sometimes it works and draws the graph but most of the time it errors:
Error using plot
Vectors must be the same length.
Error in Untitled (line 30)
plot(epscmv, cdivd
2) the graph has to finish at epsAtMmax which is 2.7671 but it stoppes at 3.5 instead..
Thank you for your help.
b=300; %mm
d=400; %mm
fc=40; %Mpa
Ecm=22*(fc/10)^0.3*10^3; %Mpa
Es=200000; %Mpa
As=2400; %mm^2
fy=400; %Mpa
epsc1=min(2.8/1000,0.7*fc^0.31/1000);
epscu=3.5/1000;
k=1.05*Ecm*epsc1/fc;
epscmv = linspace(0.05, 3.5, 500)*1E-3;
for i=1:numel(epscmv);
epscm = epscmv(i);
funC=@(epsc) (k*epsc/epsc1-(epsc/epsc1).^2)./(1+(k-2)*epsc/epsc1);
compression=@(c) b*fc*c/epscm*integral(funC,0,epscm)/1000;
tension=@(c) min(Es*(d-c)/c*epscm*As/1000,fy*As/1000);
c(i)=fsolve(@(c) compression(c)-tension(c),1);
funM=@(epsc)(k*epsc./epsc1-(epsc./epsc1).^2)./(1+(k-2)*epsc./epsc1).*(d-c(i)+(c(i)./epscm).*epsc);
M(i)=b*fc*c(i)/epscm*integral(funM,0,epscm)/1000000;
phi(i)=epscm/c(i);
cdivd(i)=c(i)/d;
if (i > 1) & (M(i)<M(i-1))
break;
end
end
[Mmax,idx]=max(M) %[kNm]
phiAtMmax=phi(idx) %[1/mm]
epsAtMmax=epscmv(idx)*1000 %[promil]
plot(epscmv, cdivd)
grid on
xlabel('epsilon cm')
ylabel('c/d')
  1 件のコメント
Shimon Katzman
Shimon Katzman 2019 年 11 月 24 日
Please HELP

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

採用された回答

Star Strider
Star Strider 2019 年 11 月 24 日
Your code does what you want it to, including the if block, and appears to produce the desired results:
Mmax =
342.497032418162
idx =
394
phiAtMmax =
2.50775914909749e-05
epsAtMmax =
2.76713426853707
Solve the plot error by limiting the ranges on both arguments:
plot(epscmv(1:idx), cdivd(1:idx))
That worked when I ran it, and the plot stops at the appropriate value of ϵ. Your code does what you want it to, including the if block, and appears to produce the desired results:
Mmax =
342.497032418162
idx =
394
phiAtMmax =
2.50775914909749e-05
epsAtMmax =
2.76713426853707
Solve the plot error by limiting the ranges on both arguments:
plot(epscmv(1:idx), cdivd(1:idx))
That worked when I ran it, and the plot stops at the appropriate value of ϵ.
  4 件のコメント
Shimon Katzman
Shimon Katzman 2019 年 11 月 26 日
Hi Star,
Can yoy please help me in the following link? I think you the only person in the world that can help me..
Thank you very much.
Star Strider
Star Strider 2019 年 11 月 26 日
As always, my pleasure!
Please see my Answer.

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

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by