Hi all,
I have a 2D array int that has fixed avues of 1 on its second column but different values on its first column. How can I select the values from its first column to be within a range of .
int = [1.8702 1.0000 ; -0.8739 1.0000 ; 3.1069 1.0000 ; 0.9228 1.0000 ;-1.1946 1.0000 ; -0.1244 1.0000 ;...
0.2662 1.0000 ;0.3586 1.0000 ;0.2288 1.0000 ;0.0003 1.0000 ;-0.2503 1.0000];
Any help would be appreicted.
Thanks.

 채택된 답변

Voss
Voss 2021년 12월 9일

0 개 추천

int(int(:,1) >= 0 & int(:,1) <= 1,1)

댓글 수: 3

Lama Hamadeh
Lama Hamadeh 2021년 12월 9일
Thank you for your reply. It is helpful, but the output is just one column (the selected elements from the first column). How can I have their assciated elements from the second column as well? In other words, I want the diemnsions of the output to be two columns with selected rows.
I know how:
int = [int(int(:,1) >= 0 & int(:,1) <= 1, 1) ...
int(int(:,1) >= 0 & int(:,1) <= 1, 2)];
Thank you.
That will work. A slightly simpler way is:
int = int(int(:,1) >= 0 & int(:,1) <= 1,:);
(I wasn't sure before if you wanted all the columns or just the first one.)

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

질문:

2021년 12월 9일

댓글:

2021년 12월 10일

Community Treasure Hunt

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

Start Hunting!

Translated by