Question
use matlab 3. Question - Interpolation and surface plots. Write a script called randomSurface.m to do the following (1). To make a random surface, make
use matlab
3. Question-Interpolation and surface plots. Write a script called randomSurface.m to do the following
(1). To make a random surface, make Z0 a 5x5 matrix of random values on the range [0, 2] (use rand).
(2). Make an X0 and Y0 using meshgrid and the vector 1:5 (use the same vector for both inputs into
meshgrid). Now, X0, Y0, and Z0 define 100 points on a surface.
(3). We are going to interpolate intermediate values to make the surface seem smooth. Make X1 and Y1
using meshgrid and the vector 1:0.1:5 (again use the same vector for both inputs into meshgrid).
(4). Make Z1 by interpolating X0, Y0, and Z0 at the positions in X1 and Y1 using cubic interpolation (interp2,
specify cubic as the interpolation method).
Help of interp2.
(5). Plot a surface plot of Z1. Set the colormap to hsv and the shading property to interp (surf, colormap,
shading).
(6). Hold on to the axes and plot the 15-line contour on the same axes (contour).
(7). Add a colorbar (colorbar).
(8). Set the color axis to be from 0 to 1 (caxis). The final figure should look something like this
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started