I need to make a function in matlab where it will not have any variables as return, only parameters, is it possible?
I need to make a function in matlab where it will not have any variables as return, only parameters, is it possible?
Adding to the previously placed link , a function can be completely empty or have only input parameters, just do not have anything 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 a function with output:
%%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; Your directory will have priority in that directory (or everywhere, if it's in path ), but it can cause confusion.