How can I retrieve values from another matrix so I can do a quiver plot?

1 回表示 (過去 30 日間)
Sancheet Hoque
Sancheet Hoque 2016 年 10 月 27 日
コメント済み: Sancheet Hoque 2016 年 10 月 28 日
I wrote a program that reads .nc files from a folder and puts filename, longitude, latitude, u(east component) and v(North Component) velocities into one structure. Each of them have their own matrix but they are related. For one file in the workspace it shows:
  • Latitude= 140x1 single
  • Longitude= 171x1 single
  • u= 171x140
  • v= 171x140
so it's almost like a graph, where latitude is the x values and longitude are the y values. The problem I'm having is that there are NaN for many of the u and v values. I want to have a separate structure with u and v values that are not NaN, and their respective Longitude and Latitude values. I was thinking that I would somehow go through every element and pick out the integers. After that I need to find out where it was in the structure. That way I can use where it was to find where to look at in the Latitude and Longitude structure. For example I have something like this in a structure (random numbers): look at txt file attached.
I want to do a quiver/velocity plot, so the corresponding points would look like x,y,u,v= 20,34,-.4,.7. These plots have a lot of data points, but I do not know how to get the respective Longitudes and Latitudes from the structures that correspond with the u and v to plot them. The example above is how I organized it in my code. Thanks!

採用された回答

KSSV
KSSV 2016 年 10 月 28 日
Let x, y be your longitude and latitude data.
[X,Y] = meshgrid(x,y) ;
quiver(X,Y,u,v) ;
  1 件のコメント
Sancheet Hoque
Sancheet Hoque 2016 年 10 月 28 日
Thanks a lot. I didn't know it would be as simple as that!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeVector Fields についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by