MATLAB: How to save variables in one function so as they can be used in other functions? so they can be used

variables

variables that are created in one function disappear when my script goes to another function. How do I make them available for all functions?

 function [A,B] = myFun(X,Y); A = mean(X); B = X+Y; end
 mat = 1:5; val = 0; [out,tmp] = myFun(mat,val);
 Y = sin(X)