# Problem using ezplot function

2 visualizzazioni (ultimi 30 giorni)
Sudipta Basu il 11 Dic 2013
Commentato: sixwwwwww il 11 Dic 2013
I am having a for loop. I want to draw a graph using ezplot for a function like this: f(x) = sin(x) (0<x<pi/4) f(x) = cos(x) (pi/4<x<pi/2) that is the function is having different definition at different intervals. But, I am getting the graph in two separate figures instead of one figure. Please help.
A part of the code is provided below: syms x t1 = 0; for i = 1:n t2 = t1+L(i); if option(i)==1 R(i)=(-(M(i,1)+M(i,2))+q(i)*L(i)^2/2)/L(i); Vx = R(i)-q(i)*x; else R(i)=(-(M(i,1)+M(i,2))+q(i)*L(i)^2/3)/L(i); qx = (1-x/L(i))*q(i); Vx = R(i) - 0.5*(qx+q(i))*x; end figure; hold on; ezplot(Vx,[t1 t2]); t1 = t1+L(i); end
##### 1 CommentoMostra -1 commenti meno recentiNascondi -1 commenti meno recenti
sixwwwwww il 11 Dic 2013
values of n, L, option etc. are missing. Please include these values so that your code can run properly

Accedi per commentare.

### Risposte (1)

sixwwwwww il 11 Dic 2013
replace this:
figure; hold on;
ezplot(Vx,[t1 t2]);
with
ezplot(Vx,[t1 t2]), hold on
It will keep the old plot as it is and will add new plot to the same figure
##### 0 CommentiMostra -2 commenti meno recentiNascondi -2 commenti meno recenti

Accedi per commentare.

### Categorie

Scopri di più su Function Creation in Help Center e File Exchange

### Community Treasure Hunt

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

Start Hunting!

Translated by