Calling a function with no arguments

43 visualizaciones (últimos 30 días)
Swati Sarangi
Swati Sarangi el 13 de Nov. de 2020
Comentada: Rik el 13 de Nov. de 2020
Hi All,
In my program , I'm trying to call a function with some input arguments but no outputs as I'm using this function for the purpose of plotting.
How should its syntax look like?
[ ] = function_name( var1,var2,var3) // This line is giving me erorr : Assigning an output to an empty array is not supported.
Please suggest me a way to handle this error.
Thanks in advance!
  1 comentario
Rik
Rik el 13 de Nov. de 2020
If you're using a function to plot, you can return the handles to the graphics object, just like the plot function does.

Iniciar sesión para comentar.

Respuestas (1)

Mario Malic
Mario Malic el 13 de Nov. de 2020
Editada: Mario Malic el 13 de Nov. de 2020
You can achieve it this way.
function function_name( var1,var2,var3)
However, imagine a situation where you'd like to edit something on the plot that you've made, then you'd have to find the handles of it which is not a problem if you have only one figure/axes, but for multiples, you could return a figure handle.
function hFigure = function_name( var1,var2,var3)
hFigure = figure(1); % if you're using it
plot(hFigure, x, y);
end
  2 comentarios
Stephen23
Stephen23 el 13 de Nov. de 2020
@Mario Malic: are you sure about that function definition syntax? The syntax given in the documentation is:
function hFigure = function_name(var1,var2,var3)
Mario Malic
Mario Malic el 13 de Nov. de 2020
Editada: Mario Malic el 13 de Nov. de 2020
I haven't had my first coffee yet! I edited the answer, thanks Stephen.

Iniciar sesión para comentar.

Categorías

Más información sobre Printing and Saving en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by