Please help with MATLAB code.
Thank you.
Just like when youre plotting y = f (x) you need to do two things – define f and define x (x is usually defined using linspace) Defining f: You can do this as an anonymous function. Start with something simple: f (s, t) = cos (s) * sin (t) Defining s and t: Were going to do this in two steps. First, were going to define the values s and t go over: s = linspace (0, 4*pi, 200);t = linspace (0, 2*pi, 100); The naive thing to try is just evaluating f (s, t) and plotting it z = f (s, t);surf (s, t, z); What happened? What error message did you get? What are the matrix dimensions of s, t, and z? Now try plot3 (s, t, z) What did that plot? Why? The problem is that we need a grid of values to pass to f, not just two arrays. This is where the meshgrid function comes in: [S, T] = meshgrid (s, t);Z = f (S, T) What are the matrix dimensions of S and T? Z? Now try plotting