Why does the following error come up for this short piece of code?

조회 수: 2 (최근 30일)
Kiran Prasad
Kiran Prasad 2017년 6월 25일
댓글: Kiran Prasad 2017년 6월 25일
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 5x1 and H is 5x5 on the first loop. Any help would be appreciated, Kiran

채택된 답변

James Tursa
James Tursa 2017년 6월 25일
What is n? A vector? Maybe you need:
H = hilb(n(i));

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Just for fun에 대해 자세히 알아보기

제품

Community Treasure Hunt

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

Start Hunting!

Translated by