append one graph to another

Hi guys, How to append one graph to another? Tried using 'hold on' but it doesn't work. Thanks.

 Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 18 de Feb. de 2014
Editada: Azzi Abdelmalek el 18 de Feb. de 2014

0 votos

Use plotyy
% Example
x=0:0.01:10
y1=sin(x)
y2=100*cos(x)
plotyy(x,y1,x,y2)

4 comentarios

Aditya
Aditya el 19 de Feb. de 2014
I just want the red lines to continue as the blue lines end.Don't want to change the y-axis. Thanks.
Azzi Abdelmalek
Azzi Abdelmalek el 19 de Feb. de 2014
Can you post your data, or something that looks like your data
Aditya
Aditya el 19 de Feb. de 2014
Editada: Azzi Abdelmalek el 19 de Feb. de 2014
for i=n:n+11
fin1(i)=u+(si*sqrt(-log(2*3.14159*si*v(i)*v(i))));
fin2(i)=u-(si*sqrt(-log(2*3.14159*si*v(i)*v(i))));
end;
plot(f(1:n));
hold on
plot(fin1(n+1:n+11),'r');
plot(fin2(n+1:n+11),'r');
Here's the code.I want to concatenate 'f' with 'fin1' and 'fin2'.The red plot should start when the blue plot ends.
Look at this example
close
clear
n=10
f=cos(0.1*(1:n)).^2
for k=n+1:n+10
fin1(k-n)=sin(0.1*k)
fin2(k-n)=cos(0.2*k)
end
plot(1:n,f,'b');
hold on
plot(n+1:n+10,fin1,'r')
plot(n+1:n+10,fin2,'r')
hold off

Iniciar sesión para comentar.

Más respuestas (1)

Mischa Kim
Mischa Kim el 19 de Feb. de 2014

0 votos

You mean something along the lines of:
x1 = 1:50; x2 = 1:10; x3 = 1:10;
y1 = rand(1,50); y2 = rand(1,10); y3 = rand(1,10);
x = [x1 x2+x1(end) x3+x1(end)+x2(end)];
y = [y1 y2 y3];
plot(x,y)

Categorías

Preguntada:

el 18 de Feb. de 2014

Comentada:

el 19 de Feb. de 2014

Community Treasure Hunt

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

Start Hunting!

Translated by