Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

MATLAB script In a third figure window utilize the subplot command to create a b

ID: 2081939 • Letter: M

Question

MATLAB script

In a third figure window utilize the subplot command to create a bar and a polar graphs. Define variable r to be a row vector containing 6 elements of ones. Define variable theta where theta starts at pi/2 and extends up to 4.5 pi in increments of4/5 pi. Create a bar graph of theta, then create a polar graph of r versus theta (consider theta to be the independent variable). Both plots must be on the same figure window, the bar graph should be on the upper half and the polar graph should be on the lower half of the plot. Add an appropriate title to each plot.

Explanation / Answer

clear all;
close all;
clc;
r = [1 1 1 1 1 1]; % row vector of six ones
theta = pi/2:(4/5)*pi:4.5*pi; %theta values
subplot(2,1,1)
bar(theta,r)
xlabel('theta')
ylabel('r')
title('bar graph of theta')
subplot(2,1,2)
polarplot(theta,r)
xlabel('theta')
ylabel('r')
title('polar graph of theta')