Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.

Topic: Piecewise function loop?
Replies: 2   Last Post: Jun 5, 2012 4:30 PM

 Messages: [ Previous | Next ]
 Shalla Posts: 1 Registered: 6/5/12
Piecewise function loop?
Posted: Jun 5, 2012 12:58 PM

I'm new to matlab and I would like to create an input function that depends on time and 1/frequency. That is, I would like to write a code that plots a sinusoidal increase for five minute blocks and then decreases exponentially until the next pulse comes. (Pulses are initiated at integer multiples of the period.)

So, something like this, which doesn't work:

% A((n.*g <= A) & (A < (n.*g + 5))) = 50.*sin( pi .* (A((n.*g <= A) & (A < (n.*g + 5))) + n.*g)/10);
%
% A(((n.*g + 5) <= A) & (A < (n + 1).*g)) = exp(-(A(((n.*g + 5) <= A) & (A < (n + 1).*g)) + (pi.*log(1/50) - (5 + n*g)))/pi);

What's the best way to code this?

Thank you!

Date Subject Author
6/5/12 Shalla
6/5/12 Omer
6/5/12 Tom Lane