Index exceeds matrix dimensions​..........​.error

when i run this code i get the index exceeds matrix dimension error
clear
a='D:\Seismic Data';
b=dir(fullfile(a));
L1=length(b);
for i=3:L1
c=dir(fullfile(a,b(i).name));
d=fullfile(a,b(i).name,c(7).name);
e=headerInfo(d);
f=e{6,6};
g=strsplit(f,':');
s1{i-2,:}=e{8,3};
s2{i-2,:}=e{5,6};
s3{i-2,:}=e{5,11};
s4{i-2,:}=g{1};
s5{i-2,:}=g{2};
end
y=[s1 s2 s3 s4 s5];
xlswrite('D:\Test MATLAB\Myprogram2.xlsx',y,'sheet1','R2')

3 件のコメント

Walter Roberson
Walter Roberson 2015 年 9 月 22 日
Which line is the error on?
D S Parihar
D S Parihar 2015 年 9 月 22 日
in 7th line
D S Parihar
D S Parihar 2015 年 9 月 22 日
for i=3 it is working well but as i=4 then is could not load all the directory in c.

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

回答 (1 件)

Sunny Billava
Sunny Billava 2015 年 9 月 22 日

0 投票

Are you sure you want to hard-code index of c to c(7) on line 5?

2 件のコメント

D S Parihar
D S Parihar 2015 年 9 月 22 日
yes c(7) is hard-code index.
Walter Roberson
Walter Roberson 2015 年 9 月 22 日
How can you be positive there will always be at least 7 files there?
Also you are not taking into account that the order of files returned is not fixed, and depends on the file system (not the operating system). If you need a particular name then you should use it.

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

カテゴリ

ヘルプ センター および File ExchangeMatrix Indexing についてさらに検索

質問済み:

2015 年 9 月 22 日

コメント済み:

2015 年 9 月 22 日

Community Treasure Hunt

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

Start Hunting!

Translated by