Calling a specific value from a matrix using a loop

2 vues (au cours des 30 derniers jours)
Nilesh
Nilesh le 4 Déc 2022
Commenté : Voss le 4 Déc 2022
Hello everyone,
I have a set of matrix, called att_power:
I need to use a for loop to call some of the values in the first column of the matrix, such as I could be calling 5, 15, 30, and 50 only.
Based on the values, I am calling, I need matlab to create matrix showing the corresponding values in the second column.
In this case, I want to matlab to create a matrixx, showing [4.2, 32, 115, 273]
Can anyone please help me on this?
Kind regards,
Nilesh

Réponse acceptée

Voss
Voss le 4 Déc 2022
vals = [5 15 30 50];
idx = ismember(att_power(:,1),vals);
result = att_power(idx,2)
  2 commentaires
Nilesh
Nilesh le 4 Déc 2022
Déplacé(e) : Voss le 4 Déc 2022
Thank you so much
Voss
Voss le 4 Déc 2022
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by