How can I obtain a certain value from the function 'find' from a 3x2 cell?
Afficher commentaires plus anciens
I need a certain variable "a" to be equal to either 1,2 or 3 according to two previous selection "Firstselection" and "Secondselection" which algo go from 1 to 3.
I have a 3x2 cell Comb = [1,2; 2,3; 1,3]. I have to assign "a" to a find function so that when Firstselection = 1 & Secondselection = 2 (and viceversa), a = 1, Firstselection = 2 & Secondselection = 3 (and viceversa), a = 2 and Firstselection = 1 & Secondselection = 3 (and viceversa), a = 3, all based on the cell Comb. I already solved it with an if cycle but now I need to apply the function find to the cell to obtain a certain value of "a" according to my 2 selections. I cannot change the cell.
7 commentaires
Stephen23
le 21 Oct 2021
"I have a 3x2 cell Comb = [1,2; 2,3; 1,3]."
What you show is not a cell array, but a simple numeric matrix.
Do you actually have a cell array (as you write) or a numeric matrix (as you show)?
Pietro Fedrizzi
le 21 Oct 2021
KSSV
le 21 Oct 2021
You can convert it o matrix using cell2mat and then use find.
Pietro Fedrizzi
le 21 Oct 2021
dpb
le 21 Oct 2021
It's not clear to me what the desired result is, sorry.
Show us the input and then the expected output...
Pietro Fedrizzi
le 21 Oct 2021
dpb
le 22 Oct 2021
Just repeating the same unclear verbiage doesn't help -- SHOW us the input and corresponding output expected.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Operators and Elementary Operations dans Centre d'aide et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!