Having issues with plotting
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
G
el 26 de Oct. de 2018
Comentada: madhan ravi
el 26 de Oct. de 2018
I keep getting: error using plot vectors must be the same length Not sure what I am doing wrong
I'm trying to plot this: the x-axis ranges from 0-1000 in intervals of 200 and on the y axis I am trying to plot values from a matrix that is 1row*1000columns
clear,clc
load('DATA_01_TYPE01.mat')
A = sig;
x = A(2,1:1000)
t=0:200:1000;
subplot(3,1,1)
plot(t,x)
0 comentarios
Respuesta aceptada
Kevin Chng
el 26 de Oct. de 2018
clear,clc
load('DATA_01_TYPE01.mat')
A = sig;
x = A(2,1:1000)
t= 0:200:1000;
subplot(3,1,1)
plot(t,x)
for plot, length of x and y must be same. You try
length(t)
length(x)
then you will notice they are different, x has 1:1000 which is 1000 elements, but t=0:200:1000, only have 5 elements.
if you try code below, you will get the plot without error
clear,clc
load('DATA_01_TYPE01.mat')
A = sig;
x = A(2,1:1000)
t=1:1:1000;
subplot(3,1,1)
plot(t,x)
because now both t and x have the same length which is 1000.
3 comentarios
Kevin Chng
el 26 de Oct. de 2018
Editada: Kevin Chng
el 26 de Oct. de 2018
Sure. refer to my code below
clear,clc
load('DATA_01_TYPE01.mat')
A = sig;
x = A(2,1:1000)
t=1:200:1000;
subplot(3,1,1)
plot(t,x(t))
Más respuestas (0)
Ver también
Categorías
Más información sobre Annotations en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!