필터 지우기
필터 지우기

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 CenterFile Exchange에서 Polymers에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by