How to plot 3 functions inside if loop??

function y=h(x,a,b,lf,t)
v=length(x);
for i=1:1:v
Q=((a-(2*a+lf-x(i)))/a)^2;
Z=sqrt(1-Q);
S=((a-x(i))/a)^2;
T=sqrt(1-S);
if ((x(i)>=(lf+a))&&(x(i)<=(lf+2*a)))
plot y(i)=((2*b)+(t)-((2.*b).*Z));
end;
if ((x(i)>=0)&&(x(i)<=a))
plot y(i)=((2*b)+(t)-2*b*T);
end;
if ((x(i)>=a)&&(x(i)<=(lf+a)))
plot y(i)=(t);
end;
end;

Risposte (2)

Look up plot() in the help. You're not even close to using it correctly. You need to set up y on a separate line, then do
y = 2*b.....whatever.
plot(t, y, 'b-');
hold on;
I don't believe the loop over i is even needed.
Tamer
Tamer il 12 Giu 2013
disp(' ')
disp('geometry parameters:')
w = input('w [mm] = ')*1e-3;
t = input('t [mm] = ')*1e-3;
a = input('r [mm] = ')*1e-3;
b = input('a [mm] = ')*1e-3;
r = input('b [mm] = ')*1e-3;
lf = input('lf [mm] = ')*1e-3;
disp(' ')
disp('material parameters:')
E = input('E [GPa] = ')*1e9;
mi = input('mi = ');
x=(0:0.01:l)% till length L
l=lf+2*a;
alpha = 1.2;
G = 0.5*E/(1+mi);
Q=((a-(2*a+lf-x))/a)^2;
Z=sqrt(1-Q);
S=((a-x)/a)^2;
T=sqrt(1-S);
y=((2*b)+(t)-((2*b)*Z));
plot (x,y);

1 Commento

still i am not coming over it i get error with mpower

Accedi per commentare.

Categorie

Scopri di più su Graphics Performance in Centro assistenza e File Exchange

Richiesto:

il 11 Giu 2013

Community Treasure Hunt

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

Start Hunting!

Translated by