MATLAB: Plot a function in 3D 3dfuntionplot I have variables a and b both defined in [-1,+1] and the function c = a / (a + b) How can I plot c in 3D to visualize the function? Best Answer RESOLUTION=20; %increase this for a finer gridt = linspace(-1,1,RESOLUTION);[a,b] = ndgrid(t,t);c = a./(a+b);surf(a,b,c);It is, however, not possible to plot it as a continuous surface, as your graphics display only has discretized output locations ("pixels"). Related SolutionsMATLAB: Doesn’t this code work voronoi([a(:,1), b(:,1), c(:,1)], [a(:,2),b(:,2),c(:,2)]) MATLAB: How to hold colorbar in contourf plot I haven't tried this entirely, but instead of cla and replotting tryfigure(1)contourf(1,b,c)'h = colorbar('YScale','log');d = log10(c);figure(2)contourf(a,b,d)a = get(1,'children');copyobj(a(1),2);This is a crude reparenting of the colorbar from the original figure to the new one. Related QuestionHow to make a plot using ERRORBAR that plots the entire mean, but only some of the error bars in MATLAB 7.8 (R2009a)Matlab is not drawing the 3D function correctly with surf commandProblem with 3D plottingUsing surflHow to create matrices from a meshgrid function
Best Answer