index error for find function

2 views (last 30 days)
ankita
ankita on 6 Mar 2014
Edited: Chandrasekhar on 7 Mar 2014
I am trying to find the value of Signal_fft_hilbert at the values of newf. But i get the error:
??? Attempted to access Signal_fft_hilbert(14.6484); index must be a positive integer or logical.
I want to find the value at exactly 14.6484. How can I find the value?
newf=aa1(:)'
for s=1:length(newf)
ppks=find(Signal_fft_hilbert(newf(s)))
end
  1 Comment
Dishant Arora
Dishant Arora on 6 Mar 2014
You might have to go for interpolation to get the value at non- integral coordinates.

Sign in to comment.

Accepted Answer

Iain
Iain on 6 Mar 2014
Ok, it looks like you've got a vector "Signal_fft_hilbert", which I'm going to call "v".
If want v(14.6484). The only way you can get v(14. ... ) is if you interpolate.
doc interp1 % will tell you all about one function for interpolation.
Alternatively, if you want the v that corresponds to something having a value you could do something like:
v( time == 14.684324)
or
v(find(time > 14.00))
  4 Comments
Chandrasekhar
Chandrasekhar on 7 Mar 2014
hope this works replace
top1{k}=freq_s(locs(k)) with
evalin('base',['top1' num2str(k) '=freq_s(locs(k))';])
this will append the 'k' value to top1 every time and creates a new variable top1k in the workspace.

Sign in to comment.

More Answers (2)

Chandrasekhar
Chandrasekhar on 6 Mar 2014
k = find(newf == 14.6484);
ppks = Signal_fft_hilbert(k);
  17 Comments
ankita
ankita on 6 Mar 2014
maybe because of the file in the first 2-3 lines. you can check the code from line 136. there the Signal_fft_hilbert is calculated.

Sign in to comment.


Niklas Nylén
Niklas Nylén on 6 Mar 2014
Edited: Niklas Nylén on 6 Mar 2014
I misunderstood the question, removed my response but kept the answer to not lose the comments below.
  3 Comments
ankita
ankita on 6 Mar 2014
aa1 =
14.6484 29.2969 43.9453 58.5938 73.2422 87.8906 102.5391
51.2695 102.5391 153.8086 205.0781 256.3477 307.6172 358.8867
65.9180 131.8359 197.7539 263.6719 329.5898 395.5078 461.4258
80.5664 161.1328 241.6992 322.2656 402.8320 483.3984 563.9648
95.2148 190.4297 285.6445 380.8594 476.0742 571.2891 666.5039
109.8633 219.7266 329.5898 439.4531 549.3164 659.1797 769.0430
124.5117 249.0234 373.5352 498.0469 622.5586 747.0703 871.5820
newf =
Columns 1 through 7
14.6484 51.2695 65.9180 80.5664 95.2148 109.8633 124.5117
Columns 8 through 14
29.2969 102.5391 131.8359 161.1328 190.4297 219.7266 249.0234
Columns 15 through 21
43.9453 153.8086 197.7539 241.6992 285.6445 329.5898 373.5352
Columns 22 through 28
58.5938 205.0781 263.6719 322.2656 380.8594 439.4531 498.0469
Columns 29 through 35
73.2422 256.3477 329.5898 402.8320 476.0742 549.3164 622.5586
Columns 36 through 42
87.8906 307.6172 395.5078 483.3984 571.2891 659.1797 747.0703
Columns 43 through 49
102.5391 358.8867 461.4258 563.9648 666.5039 769.0430 871.5820
this is the plot of Signal_fft_hilbert

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!