problem using mesh. "Matrix is singular to working precision."
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
andré nilsson
le 16 Mar 2018
Commenté : andré nilsson
le 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 commentaires
Réponse acceptée
Birdman
le 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));
Plus de réponses (0)
Voir également
Catégories
En savoir plus sur Matrices and Arrays dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!