Effacer les filtres
Effacer les filtres

for loop to draw while loop ()

1 vue (au cours des 30 derniers jours)
Mohamad Mourad
Mohamad Mourad le 5 Avr 2020
Commenté : David Hill le 16 Avr 2020
%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 commentaires
Mohamad Mourad
Mohamad Mourad le 15 Avr 2020
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 le 16 Avr 2020
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

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Polymers dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by