plot two vectors simultaneuosly on the same axis?

15 visualizaciones (últimos 30 días)
Bojan
Bojan el 28 de Mzo. de 2014
Comentada: Bojan el 28 de Mzo. de 2014
Regards. I have 2 vectors. For example a=[2 4 3 6 7 8] and b=[7 5 2 4 4 1]. I wolud like to plot them both on x axis simultaneously, for exampe in order a=2,b=7,a=4,b=5... y axis is supposed to be 0 for vector a and 1 for vector b. is this possible to do? Thank you.

Respuesta aceptada

Azzi Abdelmalek
Azzi Abdelmalek el 28 de Mzo. de 2014
a=[2 4 3 6 7 8]
b=[7 5 2 4 4 1]
x=[a ;b]
x=x(:)
y=[zeros(size(a)); ones(size(b))]
y=y(:)
plot(x,y)
  4 comentarios
Azzi Abdelmalek
Azzi Abdelmalek el 28 de Mzo. de 2014
The order is not 2 1 2 1, you can check by
disp(x)
Maybe you mean something else
Bojan
Bojan el 28 de Mzo. de 2014
Jes, sorry. This is disp(x) 2 4 3 6 7 8 7 5 2 4 4 1
for me it should be 2 7 4 5 3 2 6 4 7 4 8 1
first value of vector a, then first value of vector b, then second value of vector a ..... and so on
and x axis is supposed to be long as sum of all values in both vector: 2+7+4+5+3+2+6+4+7+4+8+1 =53 cca

Iniciar sesión para comentar.

Más respuestas (1)

Chandrasekhar
Chandrasekhar el 28 de Mzo. de 2014
Editada: Chandrasekhar el 28 de Mzo. de 2014
plot(a)
hold
plot(b)
  1 comentario
Bojan
Bojan el 28 de Mzo. de 2014
that is not what I am looking for. You should read better. Thanks anyway. Regards

Iniciar sesión para comentar.

Categorías

Más información sobre Surface and Mesh Plots en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by