How to find a value from column 1 for given column 2 and 3 values.

2 ビュー (過去 30 日間)
Yahya Khan
Yahya Khan 2018 年 9 月 1 日
編集済み: Matt J 2018 年 9 月 2 日
Hi there, new to Matlab and have a small task which I need help with.
I have three columns, first shows velocity, second shows x-coordinates and third shows y-coordinates. I want to be able to find the velocities for given x,y coordinates. I have about 36,000 values for each so basically need an efficient way to do this. Thanks in advance.
  3 件のコメント
madhan ravi
madhan ravi 2018 年 9 月 1 日
can you upload the datas as a file by clicking the paper clip button.
Yahya Khan
Yahya Khan 2018 年 9 月 1 日
I need to be able to create a control volume, so basically a square that has velocity for each point along the boundary. The csv file has u-velocity, v-velocity, x-coordinate, y-coordinate and z-coordinate. I can basically ignore the z-coordinates and work with u an v velocities separately.

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

回答 (2 件)

Matt J
Matt J 2018 年 9 月 1 日
Use griddedInterpolant
F=griddedInteprolant({x,y},velocity);
  2 件のコメント
Yahya Khan
Yahya Khan 2018 年 9 月 2 日
I've tried using griddedinterpolation but keep on getting errors such as 'grid vectors must be strictly monotonically increasing' What format do I need to have the data in? Also is it possible to create a matrix of velocity from the x,y coordinates as that would make it the most useful to work with?
Matt J
Matt J 2018 年 9 月 2 日
編集済み: Matt J 2018 年 9 月 2 日
There are several options for that which are explained in the griddedInterpolant documentation, but in this example, I intended x and y to be grid vectors.
Yes, you should give the velocity data to griddedInterpolant in matrix form, using reshape() appropriatately. If the velocity data is not sampled from a regular grid, you should probably be using scatteredInterpolant() instead.

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


ahmed nebli
ahmed nebli 2018 年 9 月 1 日
編集済み: ahmed nebli 2018 年 9 月 1 日
u can use a code like this
% A is you matrix for i=1:size(A,1) y(i)=A(i,1); %the volocity for each x , y end

カテゴリ

Help Center および File ExchangeLoops and Conditional Statements についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by