Effacer les filtres
Effacer les filtres

Index exceeds matrix dimensions error

2 vues (au cours des 30 derniers jours)
mohamad mohamad
mohamad mohamad le 10 Déc 2014
Commenté : Image Analyst le 10 Déc 2014
hi i was running this simple code,but i got this error,any idea how to fix it?
L = 140; % Length of signal
NFFT = 2^nextpow2(L); % Next power of 2 from length of y
YY = fft(rawdata,NFFT)/L;
((((((((((Index exceeds matrix dimensions.))))))))
Error in Untitled2 (line 11)
YY = fft(rawdata,NFFT)/L;
  4 commentaires
Star Strider
Star Strider le 10 Déc 2014
Next step:
In the Command Window, type
which fft -all
after the error.
I get 6 answers, all in: C:\Program Files\MATLAB\.
mohamad mohamad
mohamad mohamad le 10 Déc 2014
Modifié(e) : Star Strider le 10 Déc 2014
fft is a variable.
built-in (C:\MATLAB\R2012a\toolbox\matlab\datafun\@logical\fft) % Shadowed logical method
built-in (C:\MATLAB\R2012a\toolbox\matlab\datafun\@single\fft) % Shadowed single method
built-in (C:\MATLAB\R2012a\toolbox\matlab\datafun\@double\fft) % Shadowed double method
C:\MATLAB\R2012a\toolbox\matlab\datafun\@uint8\fft.m % Shadowed uint8 method
C:\MATLAB\R2012a\toolbox\matlab\datafun\@uint16\fft.m % Shadowed uint16 method
C:\MATLAB\R2012a\toolbox\comm\comm\@gf\fft.m % Shadowed gf method
C:\MATLAB\R2012a\toolbox\distcomp\parallel\@codistributed\fft.m % Shadowed codistributed method
C:\MATLAB\R2012a\toolbox\dsp\filterdesign\@qfft\fft.m % Shadowed qfft method
C:\MATLAB\R2012a\toolbox\ident\ident\@iddata\fft.m % Shadowed iddata method

Connectez-vous pour commenter.

Réponse acceptée

Image Analyst
Image Analyst le 10 Déc 2014
How can you take 256 samples from an array with 140 samples? Maybe you need to pad it with zeros or something
newArray = [oldArray, zeros(1, NFFT - length(oldArray))];
  6 commentaires
mohamad mohamad
mohamad mohamad le 10 Déc 2014
my vector was a column vector and could not be concatenated with row vector zeros(1, NFFT - length(rawdata)).so i changed it to zeros(NFFT - (length(rawdata)), 1)]; and it works properly thanks indeed for your fast replays
Image Analyst
Image Analyst le 10 Déc 2014
OK, glad it works, though I don't know why since the help for fft() said that it would do that padding for you.

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Matrix Indexing dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by