I am plotting the fft of the the raw data and when i change the N size the error ' Subscripted assignment dimension mismatch' shows up

1 view (last 30 days)
Dear all i am trying to plot the FFT spectrum of the raw data in a for loop. The loop runs great when i run it at N=6554 and sampling frequency as 50e4 but when i change the N size to 655 i have this strange error. I dont think it might be due to the excess data size but I assume it might be with the loop but a bit confused in solving it. Would be glad if someone could help me with a suggestion or tip...Thank you
Fs=500000;
N=input('N='); %%adjusts delta-f and it adjusts the time interval for the single FFT spectrum
k=1;
f_start=input('f_start=');
overlap=input('Overlap factor=');
f_stop=input('f_stop=');
for i=f_start:overlap:f_stop-N
x(:,k)=abs(fft(Psign(i:i+N))); %%abs value of the FFT of the time domain signal
k=k+1;
end
p=20*log10(x(2000:N/2,f_start:f_stop)); %%conversion to dB scale
image(p) %%plots surface of the spectrum
figure
plot(p)
figure
plot(filter(ones(1,10)/10,1,p))

Answers (1)

Image Analyst
Image Analyst on 8 Apr 2015
In the statement
x(i,k)=abs(fft(Psign(i:i+N)));
x(i, k) is a single element, a single number. You are trying to assign a vector of many elements into that single element. You can't do that. It can take only 1 number, not hundreds.

Categories

Find more on Fourier Analysis and Filtering in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!