problem using mesh. "Matrix is singular to working precision."
15 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
andré nilsson
il 16 Mar 2018
Commentato: andré nilsson
il 16 Mar 2018
I'm trying to plot a graident of a function using mesh and meshgrid but im getting the "Warning: Matrix is singular to working precision." when im trying to run the code. the graph is empty. is the problem that im divding with zero in my interval? how can I work around this?
if true
[X,Y] = meshgrid(-3:1:3);
f1=(3*X.^2*Y + 10*X*Y.^2)/(exp(X.^2) + 3*Y.^4) - (2*X*exp(X.^2)*(X.^3*Y + 5*X.^2*Y.^2))/(exp(X.^2) + 3*Y.^4)^2;
mesh(X,Y,f1);
end
0 Commenti
Risposta accettata
Birdman
il 16 Mar 2018
Actually, the problem is that you do matrix operation but instead, you need to do elementwise operation, which means using ./ and .* instead of / and *. Try this:
[X,Y] = meshgrid([-3:0.01:3]);
f1=@(X,Y) (3*X.^2.*Y + 10.*X.*Y.^2)./(exp(X.^2) + 3.*Y.^4) - (2.*X.*exp(X.^2).*(X.^3.*Y + 5.*X.^2*Y.^2))./(exp(X.^2) + 3*Y.^4).^2;
mesh(X,Y,f1(X,Y));
Più risposte (0)
Vedere anche
Categorie
Scopri di più su Surface and Mesh Plots in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!