How can I obtain a certain value from the function 'find' from a 3x2 cell?
이전 댓글 표시
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
Stephen23
2021년 10월 21일
"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
2021년 10월 21일
KSSV
2021년 10월 21일
You can convert it o matrix using cell2mat and then use find.
Pietro Fedrizzi
2021년 10월 21일
dpb
2021년 10월 21일
It's not clear to me what the desired result is, sorry.
Show us the input and then the expected output...
Pietro Fedrizzi
2021년 10월 21일
dpb
2021년 10월 22일
Just repeating the same unclear verbiage doesn't help -- SHOW us the input and corresponding output expected.
채택된 답변
추가 답변 (0개)
카테고리
도움말 센터 및 File Exchange에서 Operators and Elementary Operations에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!