How can I plot multiple signals in a single plot? Please give me suggestions which functions have used for this.

 Accepted Answer

% Generate som data
fs = 1000;
t=(0:1/fs:1)';
f = 10:10:40;
x = sin(2*pi*t*f);
x = x + 0.1*randn(size(x));
n = size(x, 2); % num of channels
yyaxis left
s = 0.4; % scale factor
plot(t, s*x + (0:n-1) );
yticks(-1:n)
yticklabels(["" "abc" "def" "a" "b" ""])
yyaxis right
ylim( [-1 n]/s)
yticks( [0 1]/s)

5 Comments

Sir,
How can I use different signals plot in this type? For example of my given plot.
Please , plot this three signals as like your code. Thank you.
x=sin(2*pi*f*t);
y= cos(2*pi*f*t);
z= tan(2*pi*f*t);
You club the dependent variables together and plot against the independent variable -
%Random data
t = linspace(0,100,1000);
f = 0.025;
x = sin(2*pi*f*t);
y = cos(2*pi*f*t);
z = x.*y;
plot(t, [x;y;z])
legend({'sin', 'cos', 'sin*cos'})
Dear experts, how can I plot in this type? Which function is used for this plotting?

Sign in to comment.

More Answers (1)

4 Comments

How can I plot multiple signals separately as like mentioned figure for avoiding this three signals overlapping?
My goal is to plot this type : here signal gap between another signal is 35
My experimental output plot is:
Create a timetable() object with variable names {'Input Signal', 'Clean Signal', 'Artifact'} and with 'RowTimes' set to the time vector.
Now stackedplot() that timetable object.
For example,
TT = timetable(input_signal(:), clean_signal(:), artifact(:), 'VariableNames', {'Input Signal', 'Clean Signal', 'Artifact'}, 'RowTimes', t);
stackedplot(TT);

Sign in to comment.

Categories

Asked:

on 23 Nov 2023

Commented:

on 28 Nov 2023

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!