Azzera filtri
Azzera filtri

Having issues with plotting

2 visualizzazioni (ultimi 30 giorni)
G
G il 26 Ott 2018
Commentato: madhan ravi il 26 Ott 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)

Risposta accettata

Kevin Chng
Kevin Chng il 26 Ott 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 Commenti
Kevin Chng
Kevin Chng il 26 Ott 2018
Modificato: Kevin Chng il 26 Ott 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))
madhan ravi
madhan ravi il 26 Ott 2018
+1 @ Kevin elegant

Accedi per commentare.

Più risposte (0)

Categorie

Scopri di più su 2-D and 3-D Plots in Help Center e File Exchange

Tag

Community Treasure Hunt

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

Start Hunting!

Translated by