Contour Plotting form the text file for x and y coordinates values

2 ビュー (過去 30 日間)
Yashvardhan Bhati
Yashvardhan Bhati 2022 年 8 月 22 日
コメント済み: Chunru 2022 年 8 月 22 日
I have a text file whcih contains the data for the x and y coordinates and for each coordinate i have vx,vy, and other quantities. I would like to have spatial plot or contour. I tried using contour f plot but it says Z must be 2*2 matrix whcih i dont understand as Z here is my data of velocity.
Below is how my entires look like.
XC,YC,VX,VY,Omegaz,NP
-51.0,3.0,0.0,0.0,0.0,0.0
-51.0,3.25,0.0,0.0,0.0,0.0
-51.0,3.5,0.0,0.0,0.0,0.0
-51.0,3.75,0.0,0.0,0.0,0.0
-51.0,4.0,0.0,0.0,0.0,0.0
-51.0,4.25,0.0,0.0,0.0,0.0
can you help me with the how to proceed with it. This is what i have bene trying to do.
A1=readtable('Plug.txt','ReadVariableNames',true);
AA1=table2array(A1);
X1=AA1(1:1378,1);
Y1=AA1(1:1378,2);
VY1=AA1(1:1378,4);
contourf(X1,Y1,VY1)
  4 件のコメント
Chunru
Chunru 2022 年 8 月 22 日
Then a portion of data enough for demonstrating the code.
Yashvardhan Bhati
Yashvardhan Bhati 2022 年 8 月 22 日
編集済み: Yashvardhan Bhati 2022 年 8 月 22 日
Please check if the file is sufficient or not.

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

採用された回答

Chunru
Chunru 2022 年 8 月 22 日
T = readtable("https://www.mathworks.com/matlabcentral/answers/uploaded_files/1103995/Plug%20-%20Copy.txt")
T = 54245×6 table
XC YC VX VY Omegaz NP ___ ____ ___________ ___________ _______ _____ -50 6 -1.9191e-06 2.2662e-05 0.77066 46022 -50 6.25 -1.9191e-06 2.2662e-05 0.77066 46022 -50 6.5 -1.9191e-06 2.2662e-05 0.77066 46022 -50 6.75 -1.9191e-06 2.2662e-05 0.77066 46022 -50 7 1.2339e-05 -1.805e-06 0.67463 50001 -50 7.25 1.2339e-05 -1.805e-06 0.67463 50001 -50 7.5 1.2339e-05 -1.805e-06 0.67463 50001 -50 7.75 1.2339e-05 -1.805e-06 0.67463 50001 -50 8 1.5834e-08 -4.2745e-06 0.74742 50001 -50 8.25 1.5834e-08 -4.2745e-06 0.74742 50001 -50 8.5 1.5834e-08 -4.2745e-06 0.74742 50001 -50 8.75 1.5834e-08 -4.2745e-06 0.74742 50001 -50 9 1.3008e-05 -4.0343e-05 0.77883 45183 -50 9.25 1.3008e-05 -4.0343e-05 0.77883 45183 -50 9.5 1.3008e-05 -4.0343e-05 0.77883 45183 -50 9.75 1.3008e-05 -4.0343e-05 0.77883 45183
F = scatteredInterpolant(T.XC, T.YC, T.VY);
[xmin, xmax] = bounds(T.XC);
[ymin, ymax] = bounds(T.YC);
x0 = linspace(xmin, xmax, 50);
y0 = linspace(ymin, ymax, 50);
[xq, yq] = meshgrid(x0, y0);
zq = F(xq, yq);
contourf(x0, y0, zq)
  2 件のコメント
Yashvardhan Bhati
Yashvardhan Bhati 2022 年 8 月 22 日
Well this works well, Thanks. but how do i get the Coutour legend and is there any way to make the contour plot more coarse or refine based on requirement.
Chunru
Chunru 2022 年 8 月 22 日
Specifies the levels:
contourf(x0, y0, zq, levels) % where levels is the chosen levels

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeContour Plots についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by