MATLAB: How to plot for this figure 3d x = -10:1:10;y = linspace(-10,10);[X,Y] = meshgrid(x,y);f = cos(2*pi*X).*cos(2*pi*Y);surf(X,Y,f) Best Answer Define the ‘x’ and ‘y’ vectors differently, then reduce the number of cycles in each direction. The grid lines on the surfaces are more of a callenge. Experiment with this: x = linspace(-10,10);y = linspace(-10,10);[X,Y] = meshgrid(x,y);f = cos(2*pi*X/6).*cos(2*pi*Y/6);surf(X,Y,f, 'EdgeColor','none')hold onidxv = 1:4:numel(x); % Index Vector For Grid Lines Plotsurf(X(idxv,idxv), Y(idxv,idxv), f(idxv,idxv), 'FaceAlpha',0, 'LineWidth',1.5)hold off. Related SolutionsMATLAB: Plotting the given Trigonometric functions You can use fimplicit()fun = @(x, y) y.*sin(2*x) - x.*cos(2*y);fimplicit(fun, [-10 10 -10 10]) MATLAB: How to plot for this function You forgot to use the variables you just created:x = 0:100;y = linspace(50,150,101);[X,Y] = meshgrid(x,y);f = cos((pi.*X)./50).*sin((pi.*Y)./100);% ^ not x, but X ^ not y, but Ysurf(X,Y,f)You should also avoid the habit of starting your code with clear all,close all,clc. Especially that first one should be avoided. During debugging you can use clear or clearvars to remove variables, otherwise use functions. Related QuestionHow to show the contour plot of two functions in a graphI get error saying that z should be a matrix and not a scalarHelp plotting with simple linespace and surfHow to use meshgrid and contour
Best Answer