Search code examples
matlabplotwave

MatLab, how do I plot multiple waves on top of each other?


I have this image taken from user Li-aung Yip, in his response: Is there a way to do a linear best fit from one point to another in a matrix multiple times in order to detrend a series, MatLab?

enter image description here

I would like to know given several time series how MatLab can do this.

Best, Abid


Solution

  • Assuming that the original plots (red,green,black,blue) are of variables a,b,c,d, each of which has a point for each t:

    figure;
    hold on
    plot(t,c,'-k'); %# black line
    plot(t,c+b,'-g'); %# green line added to previous
    plot(t,c+b+a,'-r'); %# red line added to previous
    plot(t,c+b+a+d,'-b'); %# blue line added to previous