On Matlab 2021, use writetable() or dlmwrite(). See help for each.
On Matlab 2018, use dlmwrite(), since writetable() was not yet in Matlab.
Use Matlab's aray capability to shorten your code.
I recommend that you rename variable l to xmax, since l and the numeral 1 look so similar in the Courier font used by Matlab.
Here is code that uses Matlab's array capability and creates the three files you requested.
sigma = sqrt(g*k.*tanh(k*h));
Good luck with your work.