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 Comments

Are you sure you have variable 'DisA' in your file 'DisA.mat'??
Yes chandra i have that file
my file is
http://www.sendspace.com/file/2uv7w5
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.
Iget same error wen i change the name of .mat file
I'm sorry.
Now, you don't need to rename your file.
Just do what I suggest for you below :)

Sign in to comment.

 Accepted Answer

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 Comments

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
Are you sure that variable 'SortOut' is a cell??
it is not a cell my file is
http://www.sendspace.com/file/efbmab
Replace
aa=a1.SortOut{1,i};%1x96
with
aa(i) = a1.SortOut(i,1);
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
No, watch carefully.
not {}, but use ()
It must be 'SortOut(i,1);'
Not 'SortOut{i,1};'
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
To get 2x80 just
aa(i,:) = a1.SortOut(i,:);
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
Now, just type
Features = [aa,bb,cc,dd];
outside the for loop,
and you'll get Features <80x8 doubles> in your workspace
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
Do this outside the for-loop
aa = cell2mat(aa');
bb = cell2mat(bb');
cc = cell2mat(cc');
dd = cell2mat(dd');
Features2 = [aa,bb,cc,dd];
Is your question solved? Was it clear for you?
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');
Please show, how do you modify the first code?
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

Sign in to comment.

More Answers (0)

Categories

Community Treasure Hunt

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

Start Hunting!