Question

In: Computer Science

MATLAB Create two surface plots in the same figure window. Be sure to label the X...

MATLAB

  1. Create two surface plots in the same figure window. Be sure to label the X and Y axes and provide a title for each plot. The top 3D surface plot should use one of the equations

Option 1:Z=sinX+sinY

Option 2:Z=sinX+cosY

Option 3:Z=cosX+cosY

and the bottom 3D surface plot should use one of the equations

Option 1:Z=sinX - sinY

Option 2:Z=sinX - cosY

Option 3:Z=cosX - cosY

For both plots, use a mesh grid with the same range for both the x-axis and y-axis. Use a range of -2π to 2π; the step (increment) of both dimensions of the grid should be 0.25.

Use a menu or listdlg command to allow the user to select which functions to use. Be sure to output which option the user selected. And, use an if statement that, based on the option chosen, creates plots with the correct functions.

Run your program twice with different user input and provide the output for each run.

Solutions

Expert Solution

top = menu('Select top plot equation',{'1:Z=sinX+sinY','2:Z=sinX+cosY','3:Z=cosX+cosY'});
bottom = menu('Select bottom plot equation',{'1:Z=sinX-sinY','2:Z=sinX-cosY','3:Z=cosX-cosY'});
x=-2*pi:.25*2*pi;
y=x;
[X,Y]=meshgrid(x,y);
subplot(2,1,1)
if top==1
fprintf('For top plot you selected sin(x)+sin(y)\n')
Z=sin(X)+sin(Y);
elseif top==2
fprintf('For top plot you selected sin(x)+cos(y)\n')
Z=sin(X)+cos(Y);
else
fprintf('For top plot you selected cos(x)+cos(y)\n')
Z=cos(X)+cos(Y);
end
surf(X,Y,Z)
subplot(2,1,2)
if bottom==1
fprintf('For bottom plot you selected sin(x)-sin(y)\n')
Z=sin(X)-sin(Y);
elseif bottom==2
fprintf('For bottom plot you selected sin(x)-cos(y)\n')
Z=sin(X)-cos(Y);
else
fprintf('For bottom plot you selected cos(x)-cos(y)\n')
Z=cos(X)-cos(Y);
end
surf(X,Y,Z)


Related Solutions

Write the line x = 0:2:20; in the Command Window of MATLAB and then create a...
Write the line x = 0:2:20; in the Command Window of MATLAB and then create a Simulink model that first loads x from the Workspace, then creates a vector y such that y = 2.5x + ex , and finally sends the vector y back to the Workspace. You will need a From Workspace block, a To Workspace block, two Constant blocks, a Product block, and a Sum block. Note that there is a sample time associated with the From...
This is a Matlab Exercise problem. Please create the Matlab code and figure for the following...
This is a Matlab Exercise problem. Please create the Matlab code and figure for the following problem using problem specifications: Plot x vs y when y=sin(x), y=cos(x), y=sin (2*x), and y=2*sin(x) when x = 1:0.1:10. Use 2 by 2 subplot, sin(x) is in location 1, cos(x) is in location 2, sin(2*x) is in location 3 and 2*sin(x) is in location 4. The plot should have: (1) x label = ‘x value’, y label = ‘y value’, legend ‘y=sin(x)’,’ y=cos(x)’,’ y=sin...
y'=y-x^2 ; y(1)= -4 Write a MATLAB program that makes two plots of the solution to...
y'=y-x^2 ; y(1)= -4 Write a MATLAB program that makes two plots of the solution to the equation using the following values. Suggest you use nested loops instead of two different loops. Be sure to label your plots. a. x0 = 1.0, step size h = .2, number of steps n = 20. b. x0 = 1.0, step size h = .05, number of steps n = 80.
Write the MATLAB code to Create a new figure. Define a theta array such that ?...
Write the MATLAB code to Create a new figure. Define a theta array such that ? 2 ≤ ? ≤ 9? 2 with increment of ? 10 ; Create a sixmember array of ones called r. Create a new polar plot of ? versus r
Two points A and B on the surface of the Earth are at the same longitude and θ = 55.0° apart in latitude as shown in the figure below.
Two points A and B on the surface of the Earth are at the same longitude and θ = 55.0° apart in latitude as shown in the figure below. Suppose an earthquake at point A creates a P wave that reaches point B by traveling straight through the body of the Earth at a constant speed of 7.20 km/s. The earthquake also radiates a Rayleigh wave that travels at 3.05 km/s. In addition to P and S waves, Rayleigh waves...
create a function in matlab that sums two m x n matrices using nested loops, then...
create a function in matlab that sums two m x n matrices using nested loops, then returns result into a new matrix. Use nesed for loops to add matrices piece by piece. Basically means, dont program simply A+B Function should perform error check to make sure both matrices have same number of rows/ columns.
Assume there are two plots of vineyard land, X and Y. If X costs twice as...
Assume there are two plots of vineyard land, X and Y. If X costs twice as much as Y and rents and discount rates are the same for each plot, the price difference can only be causes by different growth rates. a) For both plots, provide an abstract equation for the growth rate g. Assume that plot Y’s price is NPV. b) Based on your answer to (a), and assuming that the price-to-rent ratio for plot Y equals 12 and...
two types of fertilizer should be compared. For this purpose, 25 plots of the same size...
two types of fertilizer should be compared. For this purpose, 25 plots of the same size are fertilised, namely N=10 plots of Type A and M=15 plots of Type B. for the former, The average yield is 23.6 with sample variance 9.5 and for the other plots, the average is 20.1 with variance 8.9. check a) homogeneity and B) the equality of the mean values with a significance level of 10% either with parametric test methods or also with nonparametric...
1) Create a 3-dimensional figure. Label all of the relevant dimensions. Calculate the area of each...
1) Create a 3-dimensional figure. Label all of the relevant dimensions. Calculate the area of each face, the number of vertices, the perimeter of each face, the total surface area, and the volume. Express your results in both the English and the Metric system.PLEASE TYPE
Two masses are on a horizontal, frictionless surface. The plane of the surface is the x-y...
Two masses are on a horizontal, frictionless surface. The plane of the surface is the x-y plane. Mass m1 = 1.0kg is at rest while mass m2 = 2.0kg is moving in the positive x-direction at 15m/s. The two masses then undergo a collision and mass m2 is moving with a speed of 9.0m/s at an angle of 35 degrees after the collision. 1) What is the speed of the center of mass of the two masses before the collision?...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT