L
L
light132015-06-21 02:53:45
MATLAB
light13, 2015-06-21 02:53:45

Matlab, Problem in plotting a three-dimensional graph of the function F(x, y) = 1/x^3 + 1/y^3?

tried like this
[X,Y]= meshgrid(1:.1:6, -5:.1:5);
Z= (1/X.^3 + 1/Y.^3)
surf(X,Y,Z); grid on; colormap;
but it throws an error
Error using /
Matrix dimensions must agree.
how to be?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
piva, 2015-06-21
@piva

Just add dots before the division operators to do element-wise division and get a Z matrix that is the same size as the X and Y matrices.
[X,Y]= meshgrid(1:.1:6, -5:.1:5 );
Z= (1./X.^3 + 1./Y.^3)
surf(X,Y,Z); grid on; colormap;

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question