Info

この質問は閉じられています。 編集または回答するには再度開いてください。

Help with Matlab code-please

7 ビュー (過去 30 日間)
Ozmando
Ozmando 2019 年 2 月 18 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
Good afternoon,
I am trying to run the following code in MATLAB but get an error.
Error using *
Inner matrix dimensions must agree.
Error in vcqr (line 27)
e = y - x*bhat; % Generate residuals
Any help to fix the problem please?
Thanks
Oz
clear
load fish1
Z = [ones(111,1) stormy mixed];
X = [ones(111,1) d];
pihat = inv(Z'*Z)*(Z'*d);
tau = ['15';'25';'35';'45';'50';'55';'65';'75';'85'];
for i = 1:size(tau,1),
disp(i);
hamster = str2num(strcat('.',tau(i,:)));
boo = rq([ones(size(y)) Z*pihat],y,hamster);
[b,vc] = vcqr(boo,y,[ones(size(y)) Z*pihat],hamster);
[b,f,c,seq,conv] = mcmc_flat_fish1_mon2('iqrobj_fish',boo,vc,50000,y,[ones(size(y)),d],Z,hamster);
save(strcat('fish',tau(i,:),'_storm_v3_mon2'),'b','f','c','seq','conv');
[b,f,c,seq,conv] = mcmc_flat_fish2('iqrobj_fish',boo,vc,50000,y,[ones(size(y)),d],Z,hamster);
save(strcat('fish',tau(i,:),'_storm_v3_2'),'b','f','c','seq','conv');
end
% Here is the portion of the function related to the error:
vc = zeros(k,k);
b = zeros(k,2);
S = (1/n)*x'*x;
e = y - x*bhat; % Line 27
  5 件のコメント
Matt J
Matt J 2019 年 2 月 18 日
@Ozmando,
You need to check the sizes of bhat and x at the moment the error actually occurs. To do this, execute
>>dbstop if error
at the command line and then re-run the code.
Matt J
Matt J 2019 年 2 月 18 日
Ozmando commented:
Thanks Matt.
seems to be issues with size of x abd bhat. Will go through code again to try to figure out the source.
oz

回答 (0 件)

この質問は閉じられています。

Community Treasure Hunt

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

Start Hunting!

Translated by