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
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);
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Filter Analysis에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!