Matrix is singular to working precision.

1 次查看(过去 30 天)
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);

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Surface and Mesh Plots 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by