Matlab fails to create plots when called from a function

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?

 采纳的回答

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.

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Creating, Deleting, and Querying Graphics Objects 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by