"Warning: Integer operands are required for colon operator when used as index" in fft
1 回表示 (過去 30 日間)
古いコメントを表示
Guglielmo Giambartolomei
2016 年 10 月 11 日
コメント済み: Guglielmo Giambartolomei
2016 年 10 月 11 日
Hello everyone, I tried to write a script in order to perform a fft of an accelerometric signal. When I run the code the warning in object appears. Below the faulty code line (second line):
xdft1=fft(x1-mean(x1))/N1;
xdft1=xdft1(1:N1/2+1);
where x1 is the accelerometric signal and N1=length(x1). I deem the problem is in the operation N1/2 and I think I have to use the function "floor". Can you help me? Thank you very much!
0 件のコメント
採用された回答
Walter Roberson
2016 年 10 月 11 日
N1 is odd, so N1/2 is a fraction. Add 1 to that and it is still a fraction. You are then trying to index from 1 to that fraction. That will give you a warning.
You need to either prevent N1 from being odd, or else you need to use floor() or fix() or round() on the N1/2 so that it is no longer a fraction
その他の回答 (0 件)
参考
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!