I have a code in which there is an error:
%%
212 % Range
213 Range_hat(1) = Ranges(snapstart(1));
214 Rangebin_hat(1) = RangeBins(Ranges == Range_hat(1));
215 % DOA
216 [betapks,DOAidx] = findpeaks(beta(snapstart(1),80:end)); % a possible DOA range is applied 1 ~ 101 degrees
217
218 [betapks,id_temp] = sort(betapks,'descend');
219 DOAidx = DOAidx(id_temp)+79;
220 beta_pks(1) = betapks(1);
221 DOA_hat(1) = theta(DOAidx(1));
After running , the above section gives the following error:
Index exceeds the number of array elements (0).
Error in DataA_main1 (line 220)
beta_pks(1) = betapks(1);

답변 (2개)

Yazan
Yazan 2021년 7월 23일
편집: Yazan 2021년 7월 23일

0 개 추천

It seems that the findpeaks function could not find a peak, so it returned an empty vector. Check your signal, or specify some parameters for findpeaks.

댓글 수: 5

Sadiq Akbar
Sadiq Akbar 2021년 7월 23일
Thanks alot for your response. But how?
Yazan
Yazan 2021년 7월 23일
How what?
Sadiq Akbar
Sadiq Akbar 2021년 7월 23일
I mean I have already supplied the arguments beta(snapstart(1),80:end) which is a 1 x 101 array having all values of -200. So what should I change?
@Sadiq Akbar, here is another chance to read the posting guidelines:
or you can click the Community Guidelines link on this page.
When you do you'll notice that one thing it says to do is to attach your data so people can help you -- something you have not done yet (so that's how I know you didn't read the guidelines). After you do, people will see your signal (if you also post a screenshot of it plotted) and will be able to help you more and better.
save('answers.mat', 'Ranges', 'theta', 'snapstart');
Sadiq Akbar
Sadiq Akbar 2021년 7월 24일
Thank you for your response. Yes you are right, but since my file is in GBs, so cannot upload it.

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

Image Analyst
Image Analyst 2021년 7월 24일

0 개 추천

Can't you crop out a portion of it that demonstrates the error and upload that?
What are these values? Put in this code after findpeaks()
sizeOfBeta = size(beta) % Don't use a semicolon
fprintf('snapstart(1) = %f.\n', snapstart(1));
if isempty(betapks)
fprintf('There were no peaks found!\n');
uiwait(warndlg('There were no peaks found!'));
end
What do you see?

질문:

2021년 7월 23일

답변:

2021년 7월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by