MATLAB: Is it ok to have a function where the input is the output

functioninputsoutputs

i have a function where the "ebatt" is an array of numbers and every number of this array depends on it's predecessor : as it follows :
function [ebatt,epg,dps]= chargebatt(ebatt,i,sigmma,epv,ech,Rond,rbatt,Ebattmax)
ebatt(i) = ebatt(i-1).*(1-sigmma)+(epv(i)-ech(i))/Rond;
if ebatt(i)> Ebattmax
epg(i)= epv(i)-(ech(i)./Rond+(Ebattmax-ebatt(i-1))/rbatt);
ebatt(i) = Ebattmax;
dps(i) = 0;
else
epg(i) =0;
dps(i) =0;
end
is it ok to put the output of this function the same as the input ebatt

Best Answer

Yes.
function x=myfun(x)
% stuff
end
is entirely valid. A little on the boring side, but...