How can I merge three plots into one plot?
조회 수: 8 (최근 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일
편집: Sameer
2024년 12월 9일
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!