Combining Graphs into one Figure
12 views (last 30 days)
Show older comments
I am trying to combine 2 figure into 1. Even though I am using the hold command I still get 2 figures. I am extracting data from excel. I have also attached the excel table. I want to be able to compare the two figures so they need to be on top of each other. Can anyone help?
%% Part 1
%: Read the excel file using readtable function
rawTable = readtable('E.xlsx');
x = rawTable.x; %: get the excel column, Header1 (header name)
y = rawTable.B1; %: get the excel column, Header2 (header name)
figure;
plot(x,y);
title('Symmetric Inductor Susceptance vs. Iris Dimension')
hold on
x = rawTable.x2; %: get the excel column, Header1 (header name)
y = rawTable.B2; %: get the excel column, Header2 (header name)
figure;
plot(x,y);
hold off
0 Comments
Answers (1)
Dave B
on 18 Oct 2021
Edited: Dave B
on 18 Oct 2021
The command figure makes a new figure, so just remove the second call to figure and you should be in good shape!
%% Part 1
%: Read the excel file using readtable function
rawTable = readtable('E.xlsx');
x = rawTable.x; %: get the excel column, Header1 (header name)
y = rawTable.B1; %: get the excel column, Header2 (header name)
figure;
plot(x,y);
title('Symmetric Inductor Susceptance vs. Iris Dimension')
hold on
x = rawTable.x2; %: get the excel column, Header1 (header name)
y = rawTable.B2; %: get the excel column, Header2 (header name)
% Don't call figure again here!
plot(x,y);
hold off
0 Comments
See Also
Categories
Find more on Spreadsheets in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!