Plot vectors in matlab as a straight line

I have the following two vectors:
1. vector r (1*300000) . This vector has the following values:
All indices from 1 to 122001 have values 2000
All indices from 122002 to 202001 have values 7000
All indices from 202001 to 300000 have values 1200
2. vector T (1*300000). This vector has values starting from 0, and consecutive values increment by 0.000001.
My goal is to plot r vs T. There should be a 3 straight lines in the figure (2 jumps, where value of r changes from 2000 to 7000 and other where value of r changes from 7000 to 1200).
I appreciate any help.
Thanks.

 Respuesta aceptada

Walter Roberson
Walter Roberson el 30 de Oct. de 2015
Editada: Walter Roberson el 30 de Oct. de 2015
plot(T(1:122001), r(1:122001), T(122002:202001), r(122002:202001), T(202002:end), r(202002:end))

1 comentario

Jhilam Biswas
Jhilam Biswas el 30 de Oct. de 2015
Hey Walter, that's giving me the exact output which I wanted. Thankyou soo much

Iniciar sesión para comentar.

Más respuestas (1)

Thorsten
Thorsten el 30 de Oct. de 2015
Editada: Thorsten el 30 de Oct. de 2015
plot(T, r)

2 comentarios

Jhilam Biswas
Jhilam Biswas el 30 de Oct. de 2015
Hey Thorsten, I tried that before posting the question. That's not giving me 3 different continuous lines.
Thorsten
Thorsten el 30 de Oct. de 2015
So what do you see when you use this command?

Iniciar sesión para comentar.

Categorías

Más información sobre Mathematics en Centro de ayuda y File Exchange.

Etiquetas

Preguntada:

el 30 de Oct. de 2015

Comentada:

el 30 de Oct. de 2015

Community Treasure Hunt

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

Start Hunting!

Translated by