I'm just starting to learn Matlab, and I've been searching around a lot for a solution.
Basically, I just need to fplot a function and then manipulate it more for later questions.
fplot(@(x) myfunc);
function y = myfunc(x)
y = (x^3) - (4 .* x^2) - 1
end
Produces this error
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.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 234)
In fplot>@(f)singleFplot(cax,{f},limits,extraOpts,args) (line 193)
In fplot>vectorizeFplot (line 193)
In fplot (line 163)
In HWA1_2 (line 1)
Warning: Error updating FunctionLine.
The following error was reported evaluating the function in FunctionLine update: Not
enough input arguments.
It works when I just use fplot on its own.
fplot((x^3)-(4*x^2)-1)
If anyone could point out what I'm doing wrong I'd be very grateful. The reason I need it defined as a function is because I need to do more manipulations to it later on.