Combining Graphs into one Figure

9 ビュー (過去 30 日間)
Deniz Duran
Deniz Duran 2021 年 10 月 18 日
編集済み: Dave B 2021 年 10 月 18 日
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

回答 (1 件)

Dave B
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

カテゴリ

Help Center および File ExchangeSpreadsheets についてさらに検索

製品


リリース

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by