Commands for plot and subplot
22 views (last 30 days)
Show older comments
Examine the code given below in MATLAB: subplot(3,1,1); plot(t,x); subplot(3,1,2); plot(t,y); subplot(3,1,3); plot (t,z); What is the output of the above code? What do subplot and plot commands do?
0 Comments
Accepted Answer
Arif Hoq
on 27 Jan 2022
Edited: Arif Hoq
on 27 Jan 2022
Subplot: Subplot divides the current figure into row,column and the figure position.
Plot: plot creates a 2 dimension(X axes vs Y axes) figure or line plot
please check this example:
t= 0:pi/100:2*pi;
x=sin(t);
y=cos(t);
z=x+y;
figure(1)
subplot(3,1,1) % means divided into 3 row, 1 column and creats into position 1
plot(t,x) % a=X values and X is you expected output or Y axes value
subplot(3,1,2) % means divided into 3 row, 1 column and creats into position 2
plot(t,y)
subplot(3,1,3) % means divided into 3 row, 1 column and creats into position 3
plot(t,z)
if you want more please type in the command prompt:
doc plot
doc subplot
More Answers (0)
See Also
Categories
Find more on Subplots 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!