No return function in Matlab

Asked

Viewed 357 times

0

I need to do a function in Matlab where it will have no variable as return, only parameters, it is possible?

  • the link answers your question? https://www.mathworks.com/matlabcentral/answers/81489-how-to-creata-void-function-in-matlab

1 answer

1


Adding to link previously placed, a function can be completely empty or have only input parameters, just have nothing as output. Examples:

%%Em um arquivo chamado v.m
function v(a,b)
% a funcão V cria uma figura e plota or argumentos "a" e "b"
figure()
hold on
plot(a,b)

or

%%Em um arquivo chamado v.m
function v(a,b)
% esta funcão está vazia!

Example of an output function:

%%Em um arquivo chamado v.m    
function x=v(a,b)
%retorna a soma da soma dos vetores
x=sum(a)+sum(b);

To call the function, use v(a,b), in all cases. Remembering that it is good not to use existing names; yours will have priority in that directory (or everywhere, if you are in the path), but can cause confusion.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.