set f3 equal to 3.*sin(2*pi*t/15)+12*exp(-(t-50)^2/15) in matlab

Assuming that t is a vector with the desired time samples, the function values can be computed using element-wise arithmetic operations and built-in functions as follows:

main.m
t = 0:0.1:100; % example time vector
f3 = 3 .* sin(2*pi*t/15) + 12 .* exp(-(t-50).^2/15);
90 chars
3 lines

The first line defines t as a vector that ranges from 0 to 100 with a step size of 0.1. The second line defines f3 as a vector with the same length as t, where the function values are computed element-wise using the sin, exp, and power (.^) functions.

related categories

gistlibby LogSnag