필터 지우기
필터 지우기

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);

조회 수: 1 (최근 30일)
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');

답변 (1개)

Walter Roberson
Walter Roberson 2017년 5월 29일
I suspect that your time column is being interpreted as text or non-numeric. If you have R2013b or newer consider using readtable
  댓글 수: 4
Walter Roberson
Walter Roberson 2017년 5월 30일
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');

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Programming Utilities에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by