for about three days I have had this error message: Cell contents reference from a non-cell array object.
古いコメントを表示
lambda_snr_vec = ones(1,nodes);
sigma_sample = 2;
Counter = 1;
for i=1:steps
for child=1:nodes
% sampling sigma
lambda_snr = lambda_snr_vec(1,child);
sum_Delta2 = 0;
for component=1:Kg; * * _ |%%%%%the problem is here%%%%%%%| _ * *
sum_Delta2 = sum_Delta2 +y{child}{component}'*inv(eye(length(find(vector==component)))+lambda_snr* X{child}{component}'* X{child}{component})*y{child}{component};
end
A=alpha_sig+((m-1)/2);
B=beta_sig+(sum_Delta2/2);
new_sigma_sample= gamrnd(A,B);
%sampling Wg,k
for component=1:Kg
sigma_star = inv(lambda_snr * eye(cardinality_parents{child}+1) + X{child}{component}*X{child}{component}');
A = sigma_star * X{child}{component} * y{child}{component};
B = new_sigma_sample*sigma_star;
regress_par_sample{component} = mvnrnd(A,B)';
end
%sampling lambda
sum_regress_para = 0;
for component=1:Kg;
sum_regress_para = sum_regress_para + regress_par_sample{component}'*regress_par_sample{component};
end
A = alpha_sig+(Kg*(cardinality_parents{child}+1)/2);
B = beta_sig+(1/2 * new_sigma_sample* sum_regress_para);
new_lambda_sample= gamrnd(A,B);
3 件のコメント
@Mahdi Shafiee: Can you please:
- Upload the complete code (upload the code using the paperclip button if the code is large).
- Give the complete error message, which is all of the red text. There is lots of useful information in this message that we can use to help you.
Guillaume
2015 年 6 月 15 日
The error message should have given you a line where the error occurs. Which line is that? As a rule, when asking help about an error message, paste the entire error message (everything in red) in the body of the question.
M Shaka
2015 年 6 月 15 日
採用された回答
その他の回答 (4 件)
David H
2015 年 6 月 15 日
0 投票
The problem is likely that one of X or y is not defined as a cell array.
Can you put two lines of code before the error which output class(X) and class (y)? If one comes out as something that isn't "cell" look through the rest of the code to find where you might have accidentally overwritten it.
Walter Roberson
2015 年 6 月 15 日
At the command prompt, give the command
dbstop if error
and then run the program. When it stops,
if ~iscell(X)
fprintf(2,'X is not a cell!');
else
for KKK = 1 : length(X)
if ~iscell(X{KKK})
fprintf(2,'X{%d} is not a cell!', KKK);
break;
end
end
end
if ~iscell(y)
fprintf(2,'y is not a cell!');
else
for KKK = 1 : length(y)
if ~iscell(y{KKK})
fprintf(2,'y{%d} is not a cell!', KKK);
break;
end
end
end
1 件のコメント
Walter Roberson
2015 年 6 月 15 日
Your statement
y=y{child}{component}'
is overwriting all of y with the current component. You do not make the same mistake for x as you use
X=x{child}{component};
notice that the output variable "X" is not the same as the input variable "x" so the treatment of x is fine in that line. On the other hand your line 59 is going to try to access X{child}{component} and that doesn't exist.
You need to review your code and pay attention to the variable names.
カテゴリ
ヘルプ センター および File Exchange で Get Started with MATLAB についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!