How to write an equation as a function in Matlab?

To write an equation as a function in Matlab, you must first define the function using the syntax:

function y = myFunction(x)

Then, you can write the equation inside the function using the standard mathematical notation. For example, if the equation is y = 2x + 3, the function would be written as:

function y = myFunction(x)
y = 2*x + 3;
end