MATLAB: Contour plot for given x,y,z contour Dear All, I have x, y, and z data. I was unable to plot 2D contour. 1st column is x, 2nd column is y and 3rd column is z. Kindly help. Best Answer [num,txt,raw] = xlsread('Book1.xlsx') ; x = num(:,1) ; y = num(:,2) ; z = num(:,3) ; figure(1)scatter(x,y,20,z,'filled') ; colorbar%% Method 1 / Griddatanx = 500 ; ny = 500 ;[X,Y] = meshgrid(linspace(min(x),max(x),nx),linspace(min(y),max(y),ny)) ;Z =griddata(x,y,z,X,Y) ;figure(2)contour(X,Y,Z) ;figure(3)pcolor(X,Y,Z)shading interp %% Method 2 simple reshaping x = unique(x) ; nx = length(x) ;y = unique(y) ; ny = length(y) ;Z = reshape(z,ny,nx) ;figure(4)contour(x,y,Z) Related SolutionsMATLAB: Contour from .xlsx, getting “Z must be at least a 2×2 matrix” error You first need to convert you z vector into a grid to use contour()data = xlsread('data.xlsx','Sheet1','A1:C300');x = data(:,2);y = data(:,1);z = data(:,3);xg = linspace(min(x), max(x), 50);yg = linspace(min(y), max(y), 50);[X,Y]=meshgrid(xg,yg);Z = griddata(x, y, z, X, Y);contour(X,Y,Z) MATLAB: Unable to perform assignment because the size of the left side is 1-by-1 and the size of the right side is 0-by-1. You want this. S = load("data.mat") ;data = S.Fe2MnGe_new ; v = data(:,1) ; ca = data(:,2) ; z = data(:,3) ; nx = length(unique(v)) ; ny = length(unique(ca)) ; X = reshape(v,ny,nx) ; Y = reshape(ca,ny,nx) ; Z = reshape(z,ny,nx) ; contour(X,Y,Z) Related QuestionPlane y=xSimplify(~(~(x | y) & ~(y | z)))Plane fit (z=ax+by+c) to 3D point dataHow to draw a 3D plot from an excel dataHow can I plot this formula in an ellipse shape correctly, the code gives me incorrect ellipse shape (oppiste one). any help please.
Best Answer