How to vectorize this function?

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!

Antworten (1)

Alan Stevens
Alan Stevens am 10 Jan. 2021

0 Stimmen

You need a ./ (i.e. dot /)
x3=@(phi) (R-((3-2.*sin(phi))./(1-0.5.*sin(phi)).*R)/4).*cos(phi)
^

1 Kommentar

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)

Melden Sie sich an, um zu kommentieren.

Kategorien

Mehr zu Simulink finden Sie in Hilfe-Center und File Exchange

Produkte

Version

R2020b

Gefragt:

am 10 Jan. 2021

Kommentiert:

am 10 Jan. 2021

Community Treasure Hunt

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

Start Hunting!

Translated by