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.

4 Kommentare

madhan ravi
madhan ravi am 13 Mär. 2019
on which plane?
Manish Kumar
Manish Kumar am 13 Mär. 2019
On xy plane
madhan ravi
madhan ravi am 13 Mär. 2019
why not contour() ?
Manish Kumar
Manish Kumar am 13 Mär. 2019
i have tried
contour (x,y,z)
Error is:
Error using contour (line 48)
Z must be at least a 2x2 matrix.
Error in Untitled (line 1)
contour (x,y,z)

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

KSSV
KSSV am 13 Mär. 2019
Bearbeitet: KSSV am 13 Mär. 2019

3 Stimmen

[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 / Griddata
nx = 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)

Weitere Antworten (0)

Kategorien

Mehr zu Contour Plots finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 13 Mär. 2019

Bearbeitet:

am 13 Mär. 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by