I am facing this error (Attempted to access num(:,2); index out of bounds because size(num)=[14341,1]. Error in Untitled10 (line 3) rpm =num(: , 2);
Afficher commentaires plus anciens
filename = 'first.xlsx';
num = xlsread(filename);
rpm =num(: , 2);
time =num(: , 1);
f= rpm/60;
t=1/f;
N = length(num);
a=sin(2*pi*f)*t/N;
plot(f , a)
xlabel('Frequency (Hz)')
ylabel('Displacement');
title('Displacement Spectrum');
Réponses (1)
Walter Roberson
le 29 Mai 2017
0 votes
I suspect that your time column is being interpreted as text or non-numeric. If you have R2013b or newer consider using readtable
4 commentaires
arif hussain
le 29 Mai 2017
Walter Roberson
le 29 Mai 2017
Modifié(e) : Walter Roberson
le 29 Mai 2017
Please attach a sample file for us to test with.
arif hussain
le 30 Mai 2017
Walter Roberson
le 30 Mai 2017
Your time data looks like '9:29:55 PM0' and has a large number of repetitions of each value. On the other hand, you do not actually use the tie.
I suggest
filename = 'first.xlsx';
num = xlsread(filename);
rpm =num(: , 1);
f = rpm/60;
t = 1 ./ f;
N = length(num);
a = sin(2*pi*f) .* t/N;
plot(f , a)
xlabel('Frequency (Hz)')
ylabel('Displacement');
title('Displacement Spectrum');
Catégories
En savoir plus sur Axis Labels dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!