How to vectorize this function?

조회 수: 1 (최근 30일)
MrBanana
MrBanana 2021년 1월 10일
댓글: MrBanana 2021년 1월 10일
I have the following function:
x3=@(phi) (R-((3-2.*sin(phi))/(1-0.5.*sin(phi)).*R)/4).*cos(phi)
I read some articles saying I have to use elementwise operations but I still get a warning.
Thanks in advance!

답변 (1개)

Alan Stevens
Alan Stevens 2021년 1월 10일
You need a ./ (i.e. dot /)
x3=@(phi) (R-((3-2.*sin(phi))./(1-0.5.*sin(phi)).*R)/4).*cos(phi)
^
  댓글 수: 1
MrBanana
MrBanana 2021년 1월 10일
I tried this earlier but it didn't help either
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.
> In matlab.graphics.function.ParameterizedFunctionSurface>checkVectorization
In matlab.graphics.function.ParameterizedFunctionSurface.set.ZFunction
In matlab.graphics.function.ParameterizedFunctionSurface
In fsurf>singleFsurf (line 269)

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Simulink에 대해 자세히 알아보기

태그

제품


릴리스

R2020b

Community Treasure Hunt

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

Start Hunting!

Translated by