MATLAB: Does the following error come up for this short piece of code

assignment mismatchMATLAB

Hi, Whenever I try to run this code:
for i=1:3
H=hilb(n);
x = ones (n(i),1);
b=H*x;
y=mldivide(H,b);
disp(y);
end
I get the following error: "Subscripted assignment dimension mismatch". I'm not really sure why since as far as I can see and when I set debug stops b is 5×1 and H is 5×5 on the first loop. Any help would be appreciated, Kiran

Best Answer

What is n? A vector? Maybe you need:
H = hilb(n(i));
Related Question