Matrix is singular to working precision.

1 回表示 (過去 30 日間)
jack knipler
jack knipler 2016 年 4 月 13 日
編集済み: Walter Roberson 2016 年 4 月 13 日
Hi
I entered some code to produce to 3d graphs side by side.
When running, the graphs are shown with one of them not having anything on them. "Matrix is singular to working precision." is shown in the command window. If anyone could help with this problem, this is my code.
Thanks
x = -10:0.5:10;
y = -10:0.5:10;
[xx,yy] = meshgrid(x,y);
subplot(1,2,1)
zz = xx.^2 - yy.^2;
mesh(xx,yy,zz);
subplot(1,2,2)
zz = (xx * yy)*(xx.^2 - yy.^2 / xx.^2 + yy.^2);
mesh(xx,yy,zz);

採用された回答

Roger Stafford
Roger Stafford 2016 年 4 月 13 日
編集済み: Roger Stafford 2016 年 4 月 13 日
The matrix xx.^2 is indeed singular by its very nature, since its rows are all alike. When you write yy.^2 / xx.^2 you are asking for the inverse of xx.^2, and hence get the error message. I believe you meant to have a dot in the division rather than matrix division, and perhaps a dot in the multiplication:
zz = (xx .* yy) .* (xx.^2 - yy.^2 ./ xx.^2 + yy.^2);
or perhaps you meant this:
zz = (xx .* yy) .* (xx.^2 - yy.^2) ./ (xx.^2 + yy.^2);
  1 件のコメント
jack knipler
jack knipler 2016 年 4 月 13 日
That did the trick. Thank you so much

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeSurface and Mesh Plots についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by