Plot matlab中绘图函数的问题

Plot matlab中绘图函数的问题,plot,matlab-figure,Plot,Matlab Figure,我想在matlab中绘制此函数: f(x,y)=(x²+y²)^0.25*[sin²(50(x²+y²)^0.1)+1.0]; 下面是我写的: >> x = -100 : 1 : 100; //where x varies >> y = -100 : 1 : 100; //where y varies >> A = (power(x, 2)+ power(y, 2)); >> B = 50 * A; >> C = sin(power(B

我想在matlab中绘制此函数: f(x,y)=(x²+y²)^0.25*[sin²(50(x²+y²)^0.1)+1.0]; 下面是我写的:

>> x = -100 : 1 : 100; //where x varies
>> y = -100 : 1 : 100; //where y varies
>> A = (power(x, 2)+ power(y, 2));
>> B = 50 * A;
>> C = sin(power(B,0.1));
>> z = (power(A,0.25))*((power(C,2)+1)); 
??? Error using ==> mtimes
Inner matrix dimensions must agree.// how can i resolve this error??

救命啊

您之所以会出现此错误,是因为您在需要逐元素乘法(
*
)时使用了矩阵乘法(
*
)。即使更改了,您的代码也不完整,因为
x
y
是向量。您可能需要计算一个值数组的函数。这可以使用
meshgrid
完成。还有更多的信息

通过旋转,图形将如下所示:

x = -100 : 1 : 100;
y = -100 : 1 : 100;
[X,Y] = meshgrid(x,y);
A = (power(X, 2)+ power(Y, 2));
B = 50 * A;
C = sin(power(B,0.1));
z = (power(A,0.25)).*((power(C,2)+1));
surf(z)
xlabel('x')
ylabel('y')
zlabel('z')