필터 지우기
필터 지우기

getting and printing data from matrix

조회 수: 2 (최근 30일)
Esra Demirbilek
Esra Demirbilek 2022년 3월 29일
편집: Jan 2022년 3월 29일
Hello everyone,
Works: 5 8 9 15 7 12
A1: 1 3 2 3 1 2
A2: 3 2 1 1 2 3
Looking at the matrix structure given above, I want to print jobs with the value 3 in row A1 in another matrix. how can I do it?
Example for A1 ;
new matrix: 8
15
  댓글 수: 1
Jan
Jan 2022년 3월 29일
What is a "matrix structure"? Is this a struct containing the vectors 'Works', 'A1' and 'A2'? Please post some code, which creates the array.
What are "jobs"?

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

채택된 답변

Star Strider
Star Strider 2022년 3월 29일
I am not certain what the original matrix structure is, so I am taking some liberties with it.
Works = [5 8 9 15 7 12];
A1 = [1 3 2 3 1 2];
A2 = [3 2 1 1 2 3];
new_matrix = Works(A1 == 3)
new_matrix = 1×2
8 15
.

추가 답변 (1개)

Jan
Jan 2022년 3월 29일
편집: Jan 2022년 3월 29일
Maybe your data are:
X = [5 8 9 15 7 12; ...
1 3 2 3 1 2; ...
3 2 1 1 2 3];
If so, than:
match = X(2, :) == 3;
Result = X(1, match).'
Result = 2×1
8 15

카테고리

Help CenterFile Exchange에서 Resizing and Reshaping Matrices에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by