필터 지우기
필터 지우기

Conversion to double from struct is not possible

조회 수: 13 (최근 30일)
maha lakshmi
maha lakshmi 2013년 3월 1일
I am trying to concatenate (1080 *1)features for 1000 images.I have tried the following code but it shows error as Conversion to double from struct is not possible at Xall(:, i) = X;
d = dir('*.mat');
Xall = nan(1080, 1000);
for i = 1:length(d)
X=load(d(i).name);
Xall(:, i) = X; % assuming that the 1x1080 vectores are stored in X
end
please give some idea about it.
  댓글 수: 1
kash
kash 2013년 3월 1일
Type X in command window and post the variables.u an see the values in some variable,

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

답변 (2개)

Walter Roberson
Walter Roberson 2013년 3월 1일
When you use load() of a .mat file and assign the output to a variable, the resulting variable is a structure that has one field for each variable that was stored in the file. So if the variable in the file was "X" then you are going to get a field named "X" inside your structure "X".

Jan
Jan 2013년 3월 1일
A standard method to solve such problems:
Type this in the command window:
dbstop if error
Then start your program again. Matlab stops, when the error occurs and you can inspect the locally used variables in the workspace browser or in the command window:
class(X)
size(x)
X
Then, as Walter has explained already, something like this could be the solution:
Xall(:, i) = X.X;

카테고리

Help CenterFile Exchange에서 Structures에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by