Is there a way for reducing my code lines in a code for ploting
Afficher commentaires plus anciens
So I have this code for plotting and I wanna know that if there is a quicker way or a code with lesser lines like with a for loop or something can do the same thing for me.
And also there is a warning message that comes up and it doesnt show all my legend entries and I dont know why. (Warning: Ignoring extra legend entries.)
Es = 200*10^9; % Young's modulus of the solid of the steel(Pa)
Beta = 0;
h = 0.02; % Thickness(m)
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
xlabel('z')
ylabel('E(z)')
title('Porousity factor: Beta')
legend('0','0.1','0.2','0.3','0.4','0.5','0.6','0.7','0.8','0.9','1')
hold on
Beta = 0.1;
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
Beta = 0.2;
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
Beta = 0.3;
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
Beta = 0.4;
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
Beta = 0.5;
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
Beta = 0.6;
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
Beta = 0.7;
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
Beta = 0.8;
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
Beta = 0.9;
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
Beta = 1;
e1 = 1-((1-Beta).^2);
z = -h/2:0.001:h/2;
Ez = (Es*(1-(e1.*(cos((pi*z)/h)))));
plot(z,Ez)
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Mathematics dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



