Combining Graphs into one Figure
14 次查看(过去 30 天)
显示 更早的评论
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 个评论
回答(1 个)
Dave B
2021-10-18
编辑:Dave B
2021-10-18
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 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Spreadsheets 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!