Q)
a) create a matrix named as X of evenly spaced values from 0 to
50, with an increment of 10.
b) a) create a matrix named as Y of evenly spaced values from 500
to 1000, with an increment of 3.
c)a) create a matrix named as Z, the value of the 1st row is from 1
to 10, 2nd row from 2 to 20 with increment of 2, 3rd row 3 to
12.
using subplot divide the window into three rows and two columns so that the plot from d to h will appear in the same window:
d) generate a vertical bar graph of vector X. title it A bar
graph of vector X
e) generate a pie chart of vector X. title it A pie chart of vector
X
f)generate a three dimensional bar chart of vector Y. title it A 3d
bar graph of vector y
g) create a meshed surface plot of X, Y, Z
h) create a surface plot of X, Y, Z
i)what is the difference between the function used in g,h ( write
the answer in the script file)
j)save the figure as. jpg format
MATLAB CODE
%% part A
x=linspace(0,50,floor((50-0+1)/10)); %% floor takes the greatest
integer to fill argument of total number of samples
%% part b
y=linspace(500,1000,floor((1000-500+1)/3));
%% part c
z=[1 2 3 4 5 6 7 8 9 10; 2 4 6 8 10 12 14 16 18 20; 3 4 5 6 7 8 9
10 11 12];
subplot(3,2,1)
%% part d
bar(x); %% creates vertical bar graph
title('A bar graph of vector X')
Get Answers For Free
Most questions answered within 1 hours.