# 2D contour plot with data in Matlab

156 ビュー (過去 30 日間)
Manish Kumar 2019 年 5 月 11 日

Dear Experts,
I have x,y and z data attached in excel sheet. How to plot a 2D contour plot which will look like the attached image. And i want to show shome points like (x,y) = (1.364, 0.129) and (1.42, 0.162) in the contour plot.

#### 1 件のコメント

darova 2019 年 5 月 11 日

サインインしてコメントする。

### 採用された回答

Star Strider 2019 年 5 月 11 日
Yoiur data are gridded. You only need to reshape your vectors to get the matrices necessary for any contour or 3D plots you want:
[Ux,Ix] = unique(D(:,1)); % Determine Frame Lengths
dIx = diff(Ix); % Define Frame Length
Xr = reshape(D(:,1), dIx(1), []); % Create Matrix From Vector
Yr = reshape(D(:,2), dIx(1), []); % Create Matrix From Vector
Zr = reshape(D(:,3), dIx(1), []); % Create Matrix From Vector
figure
contourf(Xr,Yr,Zr)
xlabel('X')
ylabel('Y')
producing:
See the documentation on the contourf (link) function for details.
Experiment to get the result you want.

サインインしてコメントする。

### Community Treasure Hunt

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

Start Hunting!

Translated by