본문 바로가기
유용한 지식/Matlab

Matlab subplot function

by 그래도_明 2020. 9. 24.

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])

<Subplot Example Code Graph>

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 Plot Function, Basic and Useful Tips

Matlab Plot Function, Basic and Useful Tips the flower of Matlab is drawing a graph. I will share the codes I use often, so please freely scrape them and correct them. 1. Basic Code %% Setting..

ev-engineer-student.tistory.com

 

반응형

댓글