フィルターのクリア

index error for find function

9 ビュー (過去 30 日間)
ankita
ankita 2014 年 3 月 6 日
編集済み: Chandrasekhar 2014 年 3 月 7 日
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 件のコメント
Dishant Arora
Dishant Arora 2014 年 3 月 6 日
You might have to go for interpolation to get the value at non- integral coordinates.

サインインしてコメントする。

採用された回答

Iain
Iain 2014 年 3 月 6 日
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 件のコメント
ankita
ankita 2014 年 3 月 7 日
Thanks alot Lain. I had 1 more doubt. This is my code
for k=1:length(peaks)
top1{k}=freq_s(locs(k))
for s1=1:length(peaks)
xx{s1}=top1{k}*s1;
end
[xx1]=[xx(:)]';
xx2=cell2mat(xx1);
aa1(k,:)=xx2;
In the above answers you can see my output aa1. Is there a method where I can get output like for each top1 with their subscripts included like top11 for i=1,top12 for i=2..... see my basic idea is to create different arrays of top1,which is a frequency, and show the values of corresponding Signal_fft_hilbert. The user can then pick which top1 values suit them and they will get the final Signal_fft_hilbert values. Any suggestions?
Chandrasekhar
Chandrasekhar 2014 年 3 月 7 日
編集済み: Chandrasekhar 2014 年 3 月 7 日
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.

サインインしてコメントする。

その他の回答 (2 件)

Chandrasekhar
Chandrasekhar 2014 年 3 月 6 日
k = find(newf == 14.6484);
ppks = Signal_fft_hilbert(k);
  17 件のコメント
Chandrasekhar
Chandrasekhar 2014 年 3 月 6 日
the code(anki.m) doesnt execute. it is giving errors.
ankita
ankita 2014 年 3 月 6 日
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.

サインインしてコメントする。


Niklas Nylén
Niklas Nylén 2014 年 3 月 6 日
編集済み: Niklas Nylén 2014 年 3 月 6 日
I misunderstood the question, removed my response but kept the answer to not lose the comments below.
  3 件のコメント
Chandrasekhar
Chandrasekhar 2014 年 3 月 6 日
can you share the data of aa1 and Signal_fft_hilbert
ankita
ankita 2014 年 3 月 6 日
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

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by