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

Answer one or both questions: Create a function that will draw an octagonal pris

ID: 3556093 • Letter: A

Question

Answer one or both questions:

Create a function that will draw an octagonal prism as shown below. The base of the prism is a regular octagon (all the sides are equal). This function should have 3 function inputs (input parameters): an array that contains the xyz values of the point of origin, Po; scalar value for the side of the octagonal prism, and a scalar value for the height of the octagonal prism. Generate the x,y,z arrays that define the 9 faces of the pyramid (octagonal base and 8 triangles. Use fill3 command to create the faces (faces with parallel bases should be in the same color). You may either plot the front faces, set the transparency, then draw the back faces as shown below or plot all the faces and then set the transparency. You do not have to label the axes or show the point of origin. In the script file prompt the user to enter the values for the origin, the side of the base and the height and call the function. In a script file write the commands to create a plot of the function y = 5x3 - 4x2 + 4x -10. Plot, with x-values from 2 to 10 with step of 0.1 Assign a handle to the plot, then use the set function to change the line color from blue to red, change the line style to dashed, and line width to 2. Assign a handle to the axes, then use the set function to change the x-axis to log scale and the background color to blue. Assign a handle to the figure, then use the set function to color to green and the figure name to something descriptive of what is plotted.

Explanation / Answer

Code for 4
fun= @(x,y) 5*x^3 - 4*x^2 + 4*x -10
fplot(fun,[2,10],81)
k=get(gca,'Children')
set(k,'Color','red')
set(k,'LineStyle','-')
set(k,'LineWidth',2)

m=get(gcf,'CurrentAxes')
set(m,'xscale','log')
set(m,'Color','blue')

h=gcf
set(h,'Color','green')
set(h,'Name','Function')