Check out example codes for "how to write a function in matlab". It will help you in understanding the concepts better.

Code Example 1

%%%% general syntax %%%%%%%%%%%%% function [return parameters] = name_of_function(attributes) 	%%%%%%%%%%%%%%%%%%%%%%%%%%%%     body_of_the_function     %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%      end

Code Example 2

function ave = average(x)     ave = sum(x(:))/numel(x);  end

Code Example 3

function f = fact(n)     f = prod(1:n); end

Learn ReactJs, React Native from