Matlab fails to create plots when called from a function

1 view (last 30 days)
Hi there,
Whenever I launch the following code:
disp("Hello World")
x=0:0.01:10;
test_plot(x)
With test_plot() defined as such:
function test_plot(x)
plot(x,sin(x))
I get the following error message:
Error using gobjects (line 63) Inputs must be scalar numeric or a vector of array dimensions.
Error in newplot (line 47) fig = gobjects(0);
Error in test_plot (line 2) plot(x,sin(x))
Error in test (line 3) test_plot(x)
I am running Matlab 2017a on a Linux Mint 18 machine.
Anyone knows how to fix this?

Accepted Answer

Jan
Jan on 22 Sep 2017
Do you have any user-defined folders on top of the list of path folders? Then this can be the problem:
This can happen if you e.g. redefine false. Then inside gobject.m the line
errFlag = false;
can create the wrong output. But many other functions could suffer from such a shadowing also. You can check this by https://www.mathworks.com/matlabcentral/fileexchange/27861-uniquefuncnames.
To avoid shadowing of built-in function, check the names and append user-defined folders on the bottom of the path.

More Answers (0)

Tags

Community Treasure Hunt

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

Start Hunting!