getting and printing data from matrix

3 vues (au cours des 30 derniers jours)
Esra Demirbilek
Esra Demirbilek le 29 Mar 2022
Modifié(e) : Jan le 29 Mar 2022
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 commentaire
Jan
Jan le 29 Mar 2022
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"?

Connectez-vous pour commenter.

Réponse acceptée

Star Strider
Star Strider le 29 Mar 2022
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
.

Plus de réponses (1)

Jan
Jan le 29 Mar 2022
Modifié(e) : Jan le 29 Mar 2022
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

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by