フィルターのクリア

for loop to draw while loop ()

1 回表示 (過去 30 日間)
Mohamad Mourad
Mohamad Mourad 2020 年 4 月 5 日
コメント済み: David Hill 2020 年 4 月 16 日
%now P =700 ct number but I want to get same result for different P (600,700,900) in the same graph to make comparaision ,how can I plot it ?
clear all
close all
a=15;
b=60;
c=18.4;
Sy=1070;
P=700;
Py=501;
r=[a:0.01:b];
n=1;
%stress after loading
%plastic
while(r(n)<c)
%plastic region(ri<r<rp)
Sr(n)=-(Sy/2)*((P/Py)*(1-(a^2/r(n)^2))-log(r(n)^2/a^2));
So(n)=-(Sy/2)*((P/Py)*(1+(a^2/r(n)^2))-(2+log(r(n)^2/a^2)));
n=n+1;
end
%elastic
while (r(n)>=c)
%elastic region(rp<r<rp)
Sr(n)=-(Sy/2)*(((c^2/a^2)-(P/Py))*((a^2/r(n)^2)-(a^2/b^2)));
So(n)=(Sy/2)*(((c^2/a^2)-(P/Py))*((a^2/r(n)^2)+(a^2/b^2)));
n=n+1;
if n>length(r)
break
end
end
figure(1)
plot(r,Sr,'r',r,So,'b')
grid on
grid minor
  3 件のコメント
Mohamad Mourad
Mohamad Mourad 2020 年 4 月 15 日
Hello David fistly thanks you for your answers I have just a last question if c=[18.35,20.35,22.72]; like p
this mean for each p we have different c
Sr(n,k)=(-Sy/sqrt(3))*((c(k)^2/a^2)-(P(k)/Py))*((a^2/r(n)^2)-(a^2/b^2));
So(n,k)=(Sy/sqrt(3))*((c(k)^2/a^2)-(P(k)/Py))*((a^2/r(n)^2)+(a^2/b^2));
i tried to write it like that but this make error in matrix
should i make new counter for c also ?
David Hill
David Hill 2020 年 4 月 16 日
Works for me.
a=15;
b=60;
c=[18.35,20.35,22.72];
Sy=1070;
P=[600,700,900];
Py=501;
r=[a:0.01:b];
%stress after loading
%plastic
for k=1:3
n=1;
while(r(n)<c(k))
%plastic region(ri<r<rp)
Sr(n,k)=-(Sy/2)*((P(k)/Py)*(1-(a^2/r(n)^2))-log(r(n)^2/a^2));
So(n,k)=-(Sy/2)*((P(k)/Py)*(1+(a^2/r(n)^2))-(2+log(r(n)^2/a^2)));
n=n+1;
end
%elastic
while (r(n)>=c(k))
%elastic region(rp<r<rp)
Sr(n,k)=-(Sy/2)*(((c(k)^2/a^2)-(P(k)/Py))*((a^2/r(n)^2)-(a^2/b^2)));
So(n,k)=(Sy/2)*(((c(k)^2/a^2)-(P(k)/Py))*((a^2/r(n)^2)+(a^2/b^2)));
n=n+1;
if n>length(r)
break
end
end
end
figure(1)
plot(r,Sr(:,1),r,Sr(:,2),r,Sr(:,3),r,So);%whatever colors ...
grid on
grid minor

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

回答 (0 件)

カテゴリ

Help Center および File ExchangePolymers についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by