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

1 回表示 (過去 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));
  1 件のコメント
Kiran Prasad
Kiran Prasad 2017 年 6 月 25 日
Yup it should of been n(i). Thanks for the quick help

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLogical についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by