MATLAB: How to write a function

functionmatlab functionxlswrite

Please anyone can help me write this following function in matlab

Best Answer

The syntax for declaring a function in MATLAB is: function [y1,...,yN] = myfun(x1,...,xM)
In your case, the function defintion would be:
function v = func_name(m, g, k, t, r)
v = ((m*g)/k)^0.5 * (1 - exp(-t/r))./(1+exp(-t/r));
end
For further reference on writing functions: https://www.mathworks.com/help/matlab/ref/function.html