Error-Reference to non-existent field

I get an error when executing the code
clc;
clear;
a2=load('DisA.mat')
b2=load('Distance_text1.mat')
c2=load('Distance_c.mat')
d2=load('Distance_Hist.mat')
for i=1:80
aa=a2.DisA{1,i};%1x96
bb=b2.Distance_text1{1,i};%1x3
cc=c2.Distance_c{1,i};%1x4
dd=d2.Distance_Hist{1,i};%384x1
Features2{i}=[aa,bb,cc,dd'];%1x487
end
save('Features_Distance','Features2')
The error is
Reference to non-existent field 'DisA'.
Error in ==> main at 8
aa=a2.DisA{1,i};%1x96
the size of each one is
{1x80 cell}

댓글 수: 6

Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
Are you sure you have variable 'DisA' in your file 'DisA.mat'??
kash
kash 2011년 12월 23일
Yes chandra i have that file
kash
kash 2011년 12월 23일
my file is
http://www.sendspace.com/file/2uv7w5
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
No, not the file. But have you 'VARIABLE' DisA in file DisA.mat??
If it's there,
it's better if you rename your variable 'DisA' with other name.
Or rename your mat-file.
It seem both of your variable and your file have a same name.
kash
kash 2011년 12월 23일
Iget same error wen i change the name of .mat file
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
I'm sorry.
Now, you don't need to rename your file.
Just do what I suggest for you below :)

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

 채택된 답변

Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일

1 개 추천

No,
I have checked your file 'DisA.mat' and there is no variable named 'DisA'.
It's better if you try to change your code :
aa=a2.DisA{1,i}
with
aa{i} = a2.D{i}

댓글 수: 16

kash
kash 2011년 12월 23일
Thanks chandra i got answer ,
this is second part in which i get error
clc;
clear;
a1=load ('SortOut_c2.mat')
b1=load ('SortOut_text1.mat')
c1=load ('SortOut _c.mat')
d1=load ('SortOut_Hist.mat')
for i=1:80
aa=a1.SortOut{1,i};%1x96
bb=b1.SortOut{1,i};%1x3
cc=c1.SortOut{1,i};%1x4
dd=d1.SortOut{1,i};%384x1
Features{i}=[aa,bb,cc,dd'];%1x487
end
save('Features_Sort','Features')
the size is [80x2 double]
the error is
Cell contents reference from a non-cell array object.
Error in ==> main_sor at 8
aa=a1.SortOut{1,i};%1x96
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
Are you sure that variable 'SortOut' is a cell??
kash
kash 2011년 12월 23일
it is not a cell my file is
http://www.sendspace.com/file/efbmab
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
Replace
aa=a1.SortOut{1,i};%1x96
with
aa(i) = a1.SortOut(i,1);
kash
kash 2011년 12월 23일
i get this error
Cell contents reference from a non-cell array object.
Error in ==> main_sor at 8
aa(i)=a1.SortOut{i,1};%1x96
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
No, watch carefully.
not {}, but use ()
It must be 'SortOut(i,1);'
Not 'SortOut{i,1};'
kash
kash 2011년 12월 23일
Thanks chandra ,but i get result as 1x80,but the original size is
2x80,and other is i need those to be placed in column wise
so my final output must be
80 rows and 8 columns
please help
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
To get 2x80 just
aa(i,:) = a1.SortOut(i,:);
kash
kash 2011년 12월 23일
thanks chabdra,finally i get 8 values in a single cell of 80 columns,but i need it to be like this
80 rows and 8 columns
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
Now, just type
Features = [aa,bb,cc,dd];
outside the for loop,
and you'll get Features <80x8 doubles> in your workspace
kash
kash 2011년 12월 23일
thanks Chandra am gretafuk to u,,finaly can u say how to perform
80 rows and 4 column for my first program where size is 1x80
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
Do this outside the for-loop
aa = cell2mat(aa');
bb = cell2mat(bb');
cc = cell2mat(cc');
dd = cell2mat(dd');
Features2 = [aa,bb,cc,dd];
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
Is your question solved? Was it clear for you?
kash
kash 2011년 12월 23일
I get an error
Cell contents reference from a non-cell array object.
Error in ==> cell2mat at 38
if isnumeric(c{1}) || ischar(c{1}) || islogical(c{1}) || isstruct(c{1})
Error in ==> main at 17
aa = cell2mat(aa');
Chandra Kurniawan
Chandra Kurniawan 2011년 12월 23일
Please show, how do you modify the first code?
kash
kash 2011년 12월 23일
in my first code i get 4 values in a single cell,so i get 80 columns....
i want is inverse of that 4 column and 80 rows wirh wacs value in each separate cell

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

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Tables에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by