Remove zero velocities and its correnponding coordinates.

1 回表示 (過去 30 日間)
Kai5er
Kai5er 2023 年 3 月 22 日
回答済み: Pratheek 2023 年 3 月 28 日
I have 4 rows and 50,000 columns consisitng x-coordinates, y-coordinates, u-velocity, and v-velocity. So, u and v velocity are zero at some loactions and I want to get rid of those velocities and thier respective coordinates from the dataset to run my analysis.
Thank you
  1 件のコメント
Vishwa
Vishwa 2023 年 3 月 22 日
Please have a look at this Answer.

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

回答 (1 件)

Pratheek
Pratheek 2023 年 3 月 28 日
% load the dataset to the variable data
data = [];
% extract the each column to a individual column vector
x = data(:, 1);
y = data(:, 2);
u = data(:, 3);
v = data(:, 4);
% creating a logical index for the rows where u and v are both non-zero
idx = (u ~= 0) & (v ~= 0);
% use the logical index to extract only the desired rows from the original dataset
x_new = x(idx);
y_new = y(idx);
u_new = u(idx);
v_new = v(idx);
% concatenating the filtered columns back into a single matrix
data_filtered = [x_new, y_new, u_new, v_new];
% to save the filtered dataset to a new csvfile
csvwrite('your_filtered_data_file.csv', data_filtered);

カテゴリ

Help Center および File ExchangeFilter Analysis についてさらに検索

タグ

製品

Community Treasure Hunt

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

Start Hunting!

Translated by