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 comentarios

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

Iniciar sesión para comentar.

 Respuesta aceptada

Chandra Kurniawan
Chandra Kurniawan el 23 de Dic. de 2011
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 comentarios

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

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by