error:Subscript indices must either be real positive integers or logicals.....

5 ビュー (過去 30 日間)
D S Parihar
D S Parihar 2015 年 12 月 9 日
コメント済み: D S Parihar 2015 年 12 月 10 日
a=('D:\TEST');
b=dir(fullfile(a));
L1=length(b);
k=1;
for i=3:L1
c=dir(fullfile(a,b(i).name));
L2=length(c);
for j=3:L2-3
d=fullfile(a,b(i).name,c(j).name);
g1(k,:)={c(j).name};
e=load(d);
n = e/2.5114;
x1=detrend(n);
y=fft(x1);
pow=y.*conj(y);
l=length(y)/2;
freq=(-l:l-1)*250/length(y);
total_pow=sum(pow);
pk=findpeaks(pow);
k=max(pk);
k1=k-0.001;
[p2,k2]=findpeaks(pow,'MinPeakHeight',k1);
% Amax=max(p2);
k3=max(k2);
fmax=freq(k3);
if ((fmax>24.5)&(total_pow>40))
d1={'Event'};
else
d1={'Not Event'};
end
t(k,:)=[total_pow d1];
k=k+1;
end
end
i am getting following error.....
>>new_seismic_first
Subscript indices must either be real positive integers or logicals.
Error in new_seismic_first (line 39)
t(k,:)=[total_pow d1];
  2 件のコメント
Nicolas Gn
Nicolas Gn 2015 年 12 月 9 日
編集済み: Nicolas Gn 2015 年 12 月 9 日
k is not an integer or valid index for your array t.
I did not inspect your code in details but you can simply add a different counter such as u = 1; before your for loops and change it as t( u, :) and u = u+1; it should be enough.
D S Parihar
D S Parihar 2015 年 12 月 10 日
thank you Nicolas i got the mistake.

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

回答 (2 件)

Image Analyst
Image Analyst 2015 年 12 月 9 日

Walter Roberson
Walter Roberson 2015 年 12 月 9 日
findpeaks() applied to an empty signal would return empty, which is not a valid subscript.
The signal could be empty if the file is empty.

カテゴリ

Help Center および File ExchangeMATLAB Mobile Fundamentals についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by