MATLAB: How to plot 3d graphs using just matrices Values 3d plotsmeshgrid A = {1;2;5;7;10;20}; B = {1;2;5;7;10;20}'; [X Y] = meshgrid(A,B); Z = { 1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26}; surf(X,Y,Z); Best Answer The curly braces are used to create cell arrays. You want numerical arrays and need square brackets:A = [1;2;5;7;10;20];B = [1;2;5;7;10;20]';[X Y] = meshgrid(A,B);Z = [1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26; ... 1 8 18 21 25 26; 1 8 18 21 25 26; 1 8 18 21 25 26];surf(X,Y,Z);And suddenly it works :-) Related SolutionsMATLAB: Reshape an array into another a = [1 2 3 4 5 6 7 8;... 9 10 11 12 13 14 15 16;... 17 18 19 20 21 22 23 24;... 25 26 27 28 29 30 31 32];a = [a(:,1:end/2);a(:,end/2+1:end)] MATLAB: How to plot x^2+z^2=9 above the xy plane and between y=-1 and y=2 How about:syms x y z;[x,y]=meshgrid(-10:1:10);z = abs(sqrt(9-x.^2));surf(x,y,z);ylim([-1 2]) Related QuestionFFT code on time seriesHow to measure an angle of peaks in a plotHow to get a surface graph of the function f(x,y)Delete dates from a matrixPlotting a plane in three dimensions including data pointsApproximate plot for values of 0-10
Best Answer