PDA

View Full Version : Piecewise functions in MATLAB


fiendslyr
Jun1-11, 04:34 PM
So this problem involves computing and plotting the FFT in MATLAB. However, I do not know how to define a piecewise function in MATLAB. The function is as follows:

y_of_t = { 10cos(2*pi*2500*t), 0 <= t <= 1 msec
0 , else


How do I go about defining that function in MATLAB? I know how to do the plotting but just never dealt with piecewise functions in this program. Thanks.

jhae2.718
Jun1-11, 09:13 PM
Write a function using an if-else block to define the result based on t.