Remove zero velocities and its correnponding coordinates.
2 views (last 30 days)
Show older comments
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
Answers (1)
Pratheek
on 28 Mar 2023
% 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);
0 Comments
See Also
Categories
Find more on Filter Analysis in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!