Please help with the very simple problem? Full credit for full code!!! In a Matl
ID: 3559815 • Letter: P
Question
Please help with the very simple problem? Full credit for full code!!!
In a Matlab .m script, do the following:
Calculate the following arithmetic expressions:
sqrt(4+ 6^3)
1 + 5*3/ 6^2 +2^(2-4)*1/ 5.5
? ?
Do the following:
? The area of a circle is ?r
2
Define r as 5, and then find the area of a circle.
The volume of a cylinder is ?r
Define r as 3 and h as the matrix
h=[1,5,12]. Find the volume of the cylinders.
Generate an evenly spaced vector called vector1 of values from 1 to 20, n
increments of 1. (You can use the linspace command for this and the
following two)
Generate a vector called vector2 of values from zero to 2? in increments
of ?/100.
Generate a vector called vector3 containing 15 values, evenly spaced
between 4 and 20.
Calculate the sine of all the values in vector2 and plot it.
Explanation / Answer
a=sqrt(4+6^3);
fprintf('sqrt(4+6^3)= %0.2f ',a);
b=1+5*3/6^2+2^(2-4)*1/5.5;
fprintf('1+5*3/6^2+2^(2-4)*1/5.5= %0.2f ',b);
r=5;
area_circle=pi*r^2;
fprintf('The area of the circle= %0.2f ',area_circle);
h=[1,5,12];
l=length(h);
r_cylinder=3;
for i=1:length(h)
area=pi*r_cylinder^2*h(i);
fprintf('The volume of the cylinder=%0.2f ',area);
end
vector1=linspace(1,20,20);
vector2=0:pi/100:2*pi;
vector3=linspace(4,20,15);
s=sin(vector2);
plot(vector2,s);
xlabel('vector2')
ylabel('sin(vector2)')