How to write a function?

7 views (last 30 days)
Den Jaka
Den Jaka on 3 Jul 2020
Commented: Den Jaka on 3 Jul 2020
Please anyone can help me write this following function in matlab

Accepted Answer

Kanupriya Singh
Kanupriya Singh on 3 Jul 2020
Edited: Kanupriya Singh on 3 Jul 2020
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
  4 Comments
Kanupriya Singh
Kanupriya Singh on 3 Jul 2020
@Den Jaka as mentioned in the above comment, you can use the plot function to plot function v against t.
Syntax: plot(X,Y)
For further reference on plotting graphs: https://www.mathworks.com/help/matlab/ref/plot.html
Den Jaka
Den Jaka on 3 Jul 2020
Oke thanks

Sign in to comment.

More Answers (0)

Categories

Find more on 2-D and 3-D Plots in Help Center and File Exchange

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!