为什么矢量化我的 Matlab 函数会给我一个警告?
Why does vectorizing my Matlab function give me a warning?
我正在尝试在 Matlab 中绘制曲面 x^2*y^2+y^2*z^2+z^2*x^2=1
。我矢量化了我的函数,因为正如我在使用 Matlab 的微分方程 class 中学到的那样,这是一种很好的做法。然而,Matlab 给了我以下警告:
Warning: Function behaves unexpectedly on array inputs. To improve
performance, properly vectorize your function to return an output with
the same size and shape as the input arguments.
这是我的代码:
f = @(x,y,z) x.^2.*y.^2+y.^2.*z.^2+z.^2*x.^2-1;
fimplicit3(f)
我做错了什么?
所有以前关于 Matlab 向量化的 Whosebug 问题(例如 )似乎都涉及 for 循环。
你忘了单点
z.^2*x.^2-1 ==> z.^2.*x.^2-1;
f = @(x,y,z) x.^2.*y.^2+y.^2.*z.^2+z.^2.*x.^2-1;
fimplicit3(f)
我正在尝试在 Matlab 中绘制曲面 x^2*y^2+y^2*z^2+z^2*x^2=1
。我矢量化了我的函数,因为正如我在使用 Matlab 的微分方程 class 中学到的那样,这是一种很好的做法。然而,Matlab 给了我以下警告:
Warning: Function behaves unexpectedly on array inputs. To improve performance, properly vectorize your function to return an output with the same size and shape as the input arguments.
这是我的代码:
f = @(x,y,z) x.^2.*y.^2+y.^2.*z.^2+z.^2*x.^2-1;
fimplicit3(f)
我做错了什么?
所有以前关于 Matlab 向量化的 Whosebug 问题(例如
你忘了单点
z.^2*x.^2-1 ==> z.^2.*x.^2-1;
f = @(x,y,z) x.^2.*y.^2+y.^2.*z.^2+z.^2.*x.^2-1;
fimplicit3(f)