How can I merge three plots into one plot?
29 次查看(过去 30 天)
显示 更早的评论
Hello all
I have three separated graphs obtained from three separated m.files and I need to merge them into one single graph in order to comapre them to each other. How can I do that?
Thanks in advance
0 个评论
采纳的回答
Sameer
2024-12-9,9:37
编辑:Sameer
2024-12-9,9:38
HI @Mir Sahand
To merge three separate graphs into one single graph for comparison, you can follow below steps:
1. Load your data
2. Use the "hold on" command to overlay multiple plots on the same graph
Here's an example:
% Load data from the first file
data1 = load('file1.m');
x1 = data1.x;
y1 = data1.y;
% Load data from the second file
data2 = load('file2.m');
x2 = data2.x;
y2 = data2.y;
% Load data from the third file
data3 = load('file3.m');
x3 = data3.x;
y3 = data3.y;
% Plot the first graph
figure;
plot(x1, y1, 'DisplayName', 'Graph 1');
hold on; % This keeps the current plot so that new plots are added to it
% Plot the second graph
plot(x2, y2, 'DisplayName', 'Graph 2');
% Plot the third graph
plot(x3, y3, 'DisplayName', 'Graph 3');
xlabel('X-axis Label');
ylabel('Y-axis Label');
title('Combined Graph');
legend show;
Hope this helps
0 个评论
更多回答(0 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!