Remove zero velocities and its correnponding coordinates.

2 次查看(过去 30 天)
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 个)

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 CenterFile Exchange 中查找有关 Filter Analysis 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by