Matlab subplot function
One of the functions that seems easy but is quite confusing to use after a long time.
I'm uploading an example code, so please scratch it freely and correct it.
%% Setting
dt = 0.0001; % time step
t = 0:dt:0.08; % time
V1 = 220*sin(2*pi*60*t); % Data
V2 = 110*cos(2*pi*60*t); % Data
%% Plotting
figure
subplot(2,1,1) %% First graph window of 2X1
plot(t,V1)
title('Simulation Results')
xlabel('t [s]')
ylabel('V1 [V]')
xlim([0 0.04])
ylim([-300 300])
subplot(2,1,2) %% Second graph window of 2X1
plot(t,V2)
xlabel('t [s]')
ylabel('V2 [V]')
xlim([0 0.04])
ylim([-300 300])
Simply put, you can determine how to split the graph window and enter the number of rows and columns from the front in the subplot function input. In that example, the graph window was divided into 2X1 and should be in subplot (2,1,*).
You can then enter the order of the segmented graph window to draw the desired plot at that location.
The basic tips on the plot function used above are detailed in the post below.
2020/09/24 - [유용한 지식/Matlab] - Matlab Plot Function, Basic and Useful Tips
반응형
'유용한 지식 > Matlab' 카테고리의 다른 글
Get Matlab Excel Data | xlsread function (0) | 2020.09.24 |
---|---|
Using the Matlab 'for Statement' | Loop Statement (0) | 2020.09.24 |
Using Matlab 'if Statement' | Assumption Statement (0) | 2020.09.24 |
Matlab Graph Axis Tick | Plot Advanced Edit1 (0) | 2020.09.24 |
Matlab Plot Function, Basic and Useful Tips (0) | 2020.09.24 |
댓글