Error is simple I think? "Matrix is singular to working precision" and my z(matrix) is full of NaN with the last collumn being full of "-Inf".

I am unsure how to correct this as I have introduced the formula for z mathematically correct with appropriate parenthesis.

Code is as follows:

clf;

clear all;

xrange = -10:1:10;

yrange = -10:1:10;

xmat = repmat(xrange, length(yrange), 1);

ymat = repmat(yrange', 1, length(xrange));

z = (sin(sqrt(xmat.^2+ymat.^2)))/(0.1+sqrt(xmat.^2+ymat.^2));

mesh(xmat, ymat, z);

ANY HELP APPRECIATED THANKS :)

You are watching: Warning: matrix is singular to working precision.

2 comments

share

save

hide

report

100% Upvoted

This thread is archived

New comments cannot be posted and votes cannot be cast

Sort by: best

level 1

· 1y

uses_spinmap

Your problematic line looks like it's using matrix division, but I'm guessing you want element division. In other words, try this:

z = (sin(sqrt(xmat.^2+ymat.^2)))./(0.1+sqrt(xmat.^2+ymat.^2));

FYI, I think your line would be throwing a warning (yellow text) not an error (red text).

1

Share

ReportSave

level 2

Op · 1y

Omg i noticed that for the multiplication part but not for the division. That should solve it thank you greatly. Also for explaining the error vs warning. New matlab user :)

1

Share

ReportSave

More posts from the matlab community

Continue browsing in r/matlab

r/matlab

Official MATLAB subcouchsurfingcook.com

42.3k

coders

44

logged in

Created Aug 15, 2009

Join

Top posts april 16th 2020Top posts of april, 2020Top posts 2020

helpcouchsurfingcook.com coinscouchsurfingcook.com premiumcouchsurfingcook.com gifts

aboutcareerspressadvertiseblogTermsContent policyPrivacy policyMod policy

See more: Roy'S 2840 Dallas Parkway, Plano, Tx 75093, Roy'S Restaurant

Back to Top