Having issues with plotting

1 次查看(过去 30 天)
G
G 2018-10-26
评论: madhan ravi 2018-10-26
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)

采纳的回答

Kevin Chng
Kevin Chng 2018-10-26
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 个评论
Kevin Chng
Kevin Chng 2018-10-26
编辑:Kevin Chng 2018-10-26
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))

请先登录,再进行评论。

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Annotations 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by