필터 지우기
필터 지우기

Find the corresponding value of y when x is a specific value?

조회 수: 2 (최근 30일)
Cheuk Yin Wong
Cheuk Yin Wong 2022년 5월 18일
편집: Voss 2022년 5월 19일
I have a 369 x 2 x 27 matrix. The 369 rows (x value) are from 230:598. I want to find the corresponding y value when x-value is equal 280. Then, make a table with 1:27 on the first column and the corresponding values as the second column. Can anyone please advice me how to do it?
Thank you so much!!

채택된 답변

Voss
Voss 2022년 5월 18일
Maybe this
% a 3D array like yours
M = [(230:598).' rand(369,1)]+reshape(0:5:130,[1 1 27]);
size(M)
ans = 1×3
369 2 27
% find the row of M(:,1,1) where 280 is
row_idx = find(M(:,1,1) == 280,1);
% make the table
T = table((1:size(M,3)).',permute(M(row_idx,2,:),[3 2 1]));
head(T)
ans = 8×2 table
Var1 Var2 ____ ______ 1 0.6688 2 5.6688 3 10.669 4 15.669 5 20.669 6 25.669 7 30.669 8 35.669
  댓글 수: 2
Cheuk Yin Wong
Cheuk Yin Wong 2022년 5월 19일
Thank you so much! It works very well.
Voss
Voss 2022년 5월 19일
편집: Voss 2022년 5월 19일
You're welcome!

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

추가 답변 (0개)

카테고리

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

제품


릴리스

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by