Contour plot in 2D using x,y,z data

조회 수: 1 (최근 30일)
SGMukherjee
SGMukherjee 2021년 11월 6일
답변: Star Strider 2021년 11월 6일
I have x,y,z datalike this the attached text file. I would like to make a contour plot using this data. I am using the code
Sublat = Summer2015(:,2);
Sublong = Summer2015(:,1);
TECDev = Summer2015(:,3);
contourf(Sublong,Sublat,TECDev);
But there is an error.
Can you please help?
  댓글 수: 1
Sargondjani
Sargondjani 2021년 11월 6일
Please be more specific about your error

댓글을 달려면 로그인하십시오.

채택된 답변

Star Strider
Star Strider 2021년 11월 6일
Try this —
Summer2015 = readtable('https://www.mathworks.com/matlabcentral/answers/uploaded_files/791769/Summer2015.txt', 'VariableNamingRule','preserve')
Summer2015 = 2212×3 table
Var1 Var2 Var3 ______ ______ ________ 86.442 31.05 0.071639 86.434 31.009 0.075361 86.427 30.968 0.079066 86.418 30.931 0.07982 86.41 30.894 0.077607 86.403 30.854 0.073443 86.396 30.814 0.070311 86.388 30.778 0.06718 86.379 30.739 0.064148 86.374 30.7 0.056197 86.365 30.661 0.052311 86.357 30.621 0.052557 86.349 30.586 0.050918 86.343 30.548 0.044311 86.335 30.51 0.03682 86.329 30.472 0.029475
Sublat = Summer2015{:,2};
Sublong = Summer2015{:,1};
TECDev = Summer2015{:,3};
latv = linspace(min(Sublat), max(Sublat), height(Summer2015));
lonv = linspace(min(Sublong), max(Sublong), height(Summer2015));
[Lam,Lom] = ndgrid(latv,lonv);
TECDevm = griddata(Sublat, Sublong, TECDev, Lam, Lom);
figure
contourf(Lam, Lom, TECDevm)
axis('equal')
There may be Mapping Toolbox functions for this that could be more appropriate. Nevertheless, this illustrates how to create the matrices that contourf wants.
.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Contour Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by