how to vectorize a function?

조회 수: 3 (최근 30일)
Xizeng Feng
Xizeng Feng 2021년 6월 29일
답변: Xizeng Feng 2024년 9월 30일
I ran the following and got some reply:
>> y=@(x)x^2;
>> fplot(y)
警告: 函数处理数组输入时行为异常。要改善性能,请将您的函数正确向量化,以返回大小和形状与输入参数相同的输出。
> In matlab.graphics.function.FunctionLine>getFunction
In matlab.graphics.function.FunctionLine/updateFunction
In matlab.graphics.function.FunctionLine/set.Function_I
In matlab.graphics.function.FunctionLine/set.Function
In matlab.graphics.function.FunctionLine
In fplot>singleFplot (line 237)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 192)
In fplot>vectorizeFplot (line 192)
In fplot (line 162)
>>
What is the problem?

답변 (2개)

埃博拉酱
埃博拉酱 2024년 9월 28일
^是矩阵幂运算,你这里需要的应该是元素幂运算.^

Xizeng Feng
Xizeng Feng 2024년 9월 30일
thanks a lot!

카테고리

Help CenterFile Exchange에서 Big Data Processing에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!