필터 지우기
필터 지우기

how to select corresponding values to a column

조회 수: 1 (최근 30일)
Usama Bin Khalid
Usama Bin Khalid 2021년 3월 15일
댓글: David Hill 2021년 3월 16일
I have a data set with x and y...like 100 each in a column...x is a number..y is a value of a paramter
for x i have selected specific values say i have selected 1,15,30,45,60,75,90,100
now i want matlab to select corresponding values of y that are to x...
i know its simple but am dealing with something complex..juts need to know the quick answer. Thanks

채택된 답변

David Hill
David Hill 2021년 3월 15일
yourMatrix=[(1:100)',randi(100,100,1)];
y=yourMatrix([1,15,30,45,60,75,90,100],2);
  댓글 수: 2
Usama Bin Khalid
Usama Bin Khalid 2021년 3월 15일
I didnt mean this..Ok so let me re-question:
the data i have is:
A B
213 0.028698539
213.1 0.028679289
213.2 0.028659992
213.3 0.028640648
213.4 0.028621256
213.5 0.028601818
213.6 0.028582333
213.7 0.028562802
213.8 0.028543223
213.9 0.028523599
214 0.028503928
214.1 0.02848421
214.2 0.028464446
214.3 0.028444637
214.4 0.028424781
214.5 0.028404879
214.6 0.028384932
214.7 0.028364938
214.8 0.028344899
214.9 0.028324815
215 0.028304685
215.1 0.02828451
215.2 0.028264289
215.3 0.028244024
215.4 0.028223713
215.5 0.028203357
215.6 0.028182957
215.7 0.028162512
215.8 0.028142022
215.9 0.028121487
216 0.028100908
and this data goes until 1000. I wanted to extract some values of A and its corresponding values in col B
A: 213,213.5,213.8,214.3,214.6,215.31and so on..
i did this:
x=repmat([0.3 0.5],1,5)
x(1)=213
x=cumsum(x)
now i have one column with these values of A
x = 1×10
213.0000 213.5000 213.8000 214.3000 214.6000 215.1000 215.4000 215.9000 216.2000 216.7000
I want to now select values of B corresponding to these!!!
David Hill
David Hill 2021년 3월 16일
yourMatrix=[(1:100)',randi(100,100,1)];
y=yourMatrix(ismember(yourMatrix(:,1),[1,15,30,45,60,75,90,100]),2);

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

추가 답변 (0개)

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by