Error Using Plot: Vectors Must Be The Same Length
4 次查看(过去 30 天)
显示 更早的评论
Hi, I'm getting this error when trying to plot my 2 graphs: Vectors must be the same length. I am very new to matlab and I understand this is a common problem but couldn't figure out how to change my code so it works just by looking at other people's more complicated situations of the same error. It is a (22875x4 double)
This is my code (where DataPoints is the name of my file):
clc
Fs=1000
variable1=(DataPoints);
variable2=0.01:Fs/10000:length(variable1)*Fs/1000
variable3=(DataPoints);
figure(1);
plot(variable2,variable3)
variable4=variable1;
variable5=length(variable1);
variable6=Fs;
[P1,F1]=pwelch(variable4,variable5,variable6);
Figure(2);
Plot(F1,P1)
2 个评论
Torsten
2022-8-31
And do you get the same output for
numel(variable2)
numel(variable3)
?
The error message says: no. So change variable2 accordingly (e.g.
variable2 = linspace(0.01,numel(variable3),numel(variable3))
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spline Postprocessing 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!