Error in formation of matrix using variables computed in the code
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Geoff Hayes
2014-7-2
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.
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Structures 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!