find subarray for which for which the value of thefirst two colums is zero

조회 수: 1 (최근 30일)
Hello
I have an array M(20000000,9).
I need to extract the elements for which the first column value and the second column values are zero.
any ideas?
Thank you

채택된 답변

Hassaan
Hassaan 2024년 2월 4일
% Assuming M is your large matrix with size 20000000x9
% Let's create some dummy data for demonstration
rng(0); % For reproducibility
M = randi([-1, 1], 20000000, 9);
% Find rows where the first and second columns are zero
rowsWithZeros = (M(:, 1) == 0) & (M(:, 2) == 0);
% Extract those rows
extractedRows = M(rowsWithZeros, :);
% Display the size of the extracted rows to see how many we've found
size(extractedRows)
ans = 1×2
2222971 9
-----------------------------------------------------------------------------------------------------------------------------------------------------
If you find the solution helpful and it resolves your issue, it would be greatly appreciated if you could accept the answer. Also, leaving an upvote and a comment are also wonderful ways to provide feedback.
It's important to note that the advice and code are based on limited information and meant for educational purposes. Users should verify and adapt the code to their specific needs, ensuring compatibility and adherence to ethical standards.
Professional Interests
  • Technical Services and Consulting
  • Embedded Systems | Firmware Developement | Simulations
  • Electrical and Electronics Engineering
Feel free to contact me.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Programming에 대해 자세히 알아보기

태그

제품


릴리스

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by