Matrix is singular to working precision. Meshgrid

[x,y] = meshgrid(0.1:0.01:1,0.1:0.01:1);
z = ((1-x)*(cos(2*pi*y+(pi + atan((cos(2*pi*y)-1)/(2*pi*(1-y)+sin(2*pi*y)))))-...
cos(pi + atan((cos(2*pi*y)-1)/(2*pi*(1-y)+sin(2*pi*y))))))/((1-y)*(cos(2*pi*x...
+(pi + atan((cos(2*pi*x)-1)/(2*pi*(1-x)+sin(2*pi*x)))))-cos(pi + atan((cos(2*pi*x)-1)/(2*pi*(1-x)+sin(2*pi*x))))));

 Accepted Answer

You aren't using elementwise operations anywhere. You should replace every * by .* and every / by ./, that way you will not be doing matrix operations.
[x,y] = meshgrid(0.1:0.01:1,0.1:0.01:1);
z = ((1-x).*(cos(2*pi*y+(pi + atan((cos(2*pi*y)-1)./(2*pi*(1-y)+sin(2*pi*y)))))-...
cos(pi + atan((cos(2*pi*y)-1)./(2*pi*(1-y)+sin(2*pi*y))))))./((1-y).*(cos(2*pi*x...
+(pi + atan((cos(2*pi*x)-1)./(2*pi*(1-x)+sin(2*pi*x)))))-cos(pi + atan((cos(2*pi*x)-1)./(2*pi*(1-x)+sin(2*pi*x))))));
surf(x,y,z),view(45,30)

More Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!