create a function t=pe^rt in matlab

To create the function t=pe^rt in Matlab, you should start by defining a function that takes in three arguments: p, r, and t. This function will calculate the value of pe^rt by multiplying p with the exponential of rt.

main.m
function result = exponential(p, r, t)
    result = p*exp(r*t);
end
68 chars
4 lines

The exp function in Matlab returns the exponential function e^x, where x is the input argument. In this case, we use r*t as the input argument to get e^(rt).

Once you have defined this function, you can call it with values for p, r, and t to calculate the result.

For example:

main.m
>> t = exponential(2, 0.1, 5)
t =
   2.0138
44 chars
4 lines

This calculates the value of 2e^(0.1*5), which is approximately equal to 2.0138.

gistlibby LogSnag