Function plotting with fplot() - Error

Hi there,

I am pretty new to Octave and to any other similar programs, so forgive me please if I missed something.

I am trying the following code, for example:

Function_Test

y=@(x) x.^2;
fplot (y, [-5 5]);

A black bordered square will appear in the foreground with the text ‘@(x) x.2’.fplot_problem

After clicking Edit->Clear figure the box remains. I have tried

legend("hide");
delete(findobj());

without any succes.
Furthermore the legend(), title() commands do not take any effects.

At the Command Window the following errors appear:

Function_Test

c =

    5   20

error: 'retval' undefined near line 25, column 25
error: called from
    sum at line 28 column 1
    mean at line 153 column 9
    legend>update_icon_position at line 1288 column 10
    legend>update_texticon_position at line 1217 column 9
    legend>update_layout_cb at line 920 column 10
    legend at line 299 column 5
    fplot at line 233 column 7
    Function_Test at line 2 column 1
error: delete: first argument must be a filename or graphics handle
error: called from
    delete at line 68 column 5
    create_item>@<anonymous> at line 1064 column 30
    delete at line 65 column 5
    closereq at line 44 column 5
    close at line 119 column 5

The same error with the built in functions:

clf;
fplot (@cos, [0, 2*pi]);
c =

    5   20

error: 'retval' undefined near line 25, column 25
error: called from
    sum at line 28 column 1
    mean at line 153 column 9
    legend>update_icon_position at line 1288 column 10
    legend>update_texticon_position at line 1217 column 9
    legend>update_layout_cb at line 920 column 10
    legend at line 299 column 5
    fplot at line 233 column 7
title ("fplot() single function");
error: delete: first argument must be a filename or graphics handle
error: called from
    delete at line 68 column 5
    create_item>@<anonymous> at line 1064 column 30
    delete at line 65 column 5
    closereq at line 44 column 5
    close at line 119 column 5
title ("fplot() single function");![fplot_problem|550x410]

The plot() function is working fine.

My system

  • 64bit Windows 10 Pro 20H2 19042.1165
  • x86_64-w64-mingw32
  • Graphics card: nVidia Quadro M1000M
  • Octave version: 6.1.0
  • Installation method: Downloaded and installed “octave-6.1.0-w64-installer.exe” from Download

Any help would be appreciated. Thanks in advance.

Cheers,
bulgakov

It looks like a builtin function was overwritten. Can you restart Octave and run your code again?

Is any of your own files named, “fplot.m”, “sum.m”, “legend.m” in the current directory?

I had an own file in the directory called as “sum.m”. I renamed it and now it is working fine.

Also the legend commands take effects.

Thank you very much.

1 Like