Plotting certain values of a matrix

Hello I have a 100x1 matrix and would like to plot n=2 and n=100 values against x how would I go about doing this? Thanks for any help

 Respuesta aceptada

madhan ravi
madhan ravi el 17 de Mzo. de 2019
plot(repmat(100,100,1),x)
% ^^^-—-—-n
hold on
plot(repmat(2,100,1),x)

9 comentarios

Josh
Josh el 17 de Mzo. de 2019
How do I use my N=100x1 matrix in this method?
madhan ravi
madhan ravi el 17 de Mzo. de 2019
Not clear what your trying to do.
Josh
Josh el 17 de Mzo. de 2019
I have a matrix 'N' which is 100x1, I would like to plot the second and last value against x. How do I do this?
madhan ravi
madhan ravi el 17 de Mzo. de 2019
Editada: madhan ravi el 17 de Mzo. de 2019
size(x) ?
plot(N([1 end]),x([1 end]))
Josh
Josh el 17 de Mzo. de 2019
Sorry I don't follow, it didn't seem to work, what do the 1's and end's do? Sorry very new to Matlab.
madhan ravi
madhan ravi el 17 de Mzo. de 2019
Editada: madhan ravi el 17 de Mzo. de 2019
Sorry it was supposed to be :
[2 end] % second and last element
Josh
Josh el 17 de Mzo. de 2019
Thanks think I got it now. Sorry one more thing, how could I add another line to this plot? eg: 'y' It is a bit confusing.
madhan ravi
madhan ravi el 17 de Mzo. de 2019
Editada: madhan ravi el 17 de Mzo. de 2019
'y' represents color of the plot which is yellow.
See my original answer after using hold on plot another line to the same figure
doc hold
doc plot
I suggest you to do MATLAB onramp course which is free and takes few hours to complete by then you will get know the basics of MATLAB.
Josh
Josh el 17 de Mzo. de 2019
Thanks for the help

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Preguntada:

el 17 de Mzo. de 2019

Comentada:

el 17 de Mzo. de 2019

Community Treasure Hunt

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

Start Hunting!

Translated by