Error in formation of matrix using variables computed in the code

2 views (last 30 days)
I want to form a row matrix "test" with the variables as shown below.
test = [Energy Correlation Contrast Homogeneity Entropy];
These variables are computed in my code and the code is running smoothly till calculation of the variables. However it is showing some error in forming the matrix "test".
This is the output that I am getting:
Energy =
Energy: 2.2724e-007
Correlation =
Correlation: 0.0172
Contrast =
Contrast: 1.4265e+006
Homogeneity =
Homogeneity: 0.0044
Entropy =
0.9959
??? Error using ==> horzcat The following error occurred converting from double to struct: Error using ==> struct Conversion to struct from double is not possible.
Error in ==> maculaedema at 171 test = [Energy Correlation Contrast Homogeneity Entropy];
>>
Can anyone help me in overcoming this error......
  1 Comment
Geoff Hayes
Geoff Hayes on 2 Jul 2014
How are you computing the variables? i.e. what is the code for each?
From the above output, it appears that Energy, Correlation, Contrast and Homogeneity are all structs with fields matching their names (for example Energy.Engery=2.2724e-007). Entropy, on the other hand, appears just to be a double.
I think that this mixture of structs and doubles is true given the error message that is telling you that the code cannot concatenate structs and doubles (the conversion to struct from double is not possible).
Either all variables should be structs, or all doubles. And I think it makes more sense to have all as doubles since there doesn't seem to be any advantage to having structs with a single field whose name is the same as the struct.

Sign in to comment.

Answers (0)

Categories

Find more on Structures in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!