Azzera filtri
Azzera filtri

Matrix is singular to working precision.

1 visualizzazione (ultimi 30 giorni)
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);

Risposta accettata

Roger Stafford
Roger Stafford il 13 Apr 2016
Modificato: Roger Stafford il 13 Apr 2016
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);

Più risposte (0)

Community Treasure Hunt

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

Start Hunting!

Translated by