2D contour plot with data in Matlab
조회 수: 4 (최근 30일)
이전 댓글 표시
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.![Screenshot (45).png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/218970/Screenshot%20(45).png)
![Screenshot (45).png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/218970/Screenshot%20(45).png)
채택된 답변
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:
[D,S] = xlsread('Book1.xlsx');
[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:
![2D contour plot with data in Matlab - 2019 05 11.png](https://www.mathworks.com/matlabcentral/answers/uploaded_files/218983/2D%20contour%20plot%20with%20data%20in%20Matlab%20-%202019%2005%2011.png)
Experiment to get the result you want.
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Contour Plots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!