MATLAB: How to plot the addition of the following continuous time signal; should I determine a function as x1(t) and then plot the addition of the 2 functions
continuous time signalMATLAB
x1(t) = {2 -3<t<0 (this is the piecemeal function)
{t/3 0<t<3
{0 otherwise
using t = -10:0.01:10 plot the following in a figure
x1(t+1) &
x1[(t/2)-1]
Best Answer
x1 = @(t) (-3 < t & t < 0).*(-1) + (0 < t & t < 3).*t/3;
If all the peaks have the same parameterised formula
f = @(A,B,C,x)(A.*exp(-(1-x./B).^2./C);
for i = 1:numel(x)
y(i) = sum(f(A,B,C,x(i)));
end
Its not quick, but it will do the job for 100s of thousands of peaks. - You'll need to supply "x".
Alternatively, a lot quicker, if you use "bsxfun", and a bit of intelligence, you'll be able to get rid of the loop. - But you won't be able to handle quite so many peaks.
Best Answer