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