How to solve 'Index exceeds the number of array elements (1)'
2 次查看(过去 30 天)
显示 更早的评论
Hello
I have to compute the power spectrum of EEG and LFP signals for an assignment. I have written a function for computing the autospectrum and I have to use the imagesc function in order to generate the power spectra. Due to requirements for my assignment, I cannot use the function spectrogram.
Computing the autospectrum values works fine however when I have to plot the spectra, I get the error "Index exceeds the number of array elements (1)". I am writing this for my code for plotting the spectrograms:
% Plotting spectrogram
b = F < 200; % Boolean variable indicating frequency range
figure
imagesc((t(1:min(N_col))/60),F(b),conv2(10*log10(P_norm(b,:)),ones(5,2)/10,'same'))
caxis([-3 3])
set(gca,'YDir','default')
colormap jet
xlabel('Time (min)')
ylabel('Frequency (Hz)')
h=colorbar;
ylabel(h,'Power relative to baseline (dB)')
title([TT.BRAINREGION{j} ', Dose:' num2str(TT.DOSE(j)) 'mg/kg'])
pause
Is there some sort of error in the Imagesc line? I am unsure how to solve the issue.
3 个评论
Kaashyap Pappu
2019-10-25
There is a chance the value of "b" is too high for indexing into an array. However it is hard to say what exactly is causing the error, as the cyclist has already mentioned.
KALYAN ACHARJYA
2019-10-25
Hello Lima,
Please provide the entire code along with data, it can be easily detectable in 1 min, rather than guessing.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 AI for Signals 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!