If i have two signals that i generated before, how can i make one composite signal out of them.
From my understanding composite signal is to let the two signals appear on the same plot (overlap)
so what is the syntax need to prodece that composite signal ??
Note: poth signals have the same time interval.
You need to use the
holdfunction to retain the first plot while you draw the second one over it. Here’s an example:hold offreleases the “hold” and if you plot anything now, the previous plots are not retained. It’s good practice to release the hold so that you don’t inadvertently keep layering multiple plots (unless of course, that’s the intention).If you have two signals of widely ranging amplitudes, one option is to scale them so that they’re of comparable amplitudes. This can be achieved for e.g., by normalizing both to a max of 1. E.g.:
You might have to make a note or mention (where ever you’re using this) that the signals have been normalized so that it is clear.
Alternately you can use the
plotyyfunction which lets you plot two curves with a y-axis for each. E.g.:EDIT 2:
To change the colors in
plotyy, you need to use the handles of the lines. Continuing from the above example,Here I’ve shown two ways to set the color. One is using in-built color strings (
'r'-> red,'m'-> magenta,'c'-> cyan,'g'-> green,'b'-> blue,'y'-> yellow,'k'-> black,'w'-> white) and the other is by a 3 element numeric RGB vector which can take values from 0 to 1.Sometimes, it is desirable to not have the y-axes colored (I don’t like them that way). To change them to black, set the value of the
'ycolor'property foraxto black.