- compare 4th element of A{1} with A{2} all element
- if any of them is 1 it means it is inside that cell. it will give you output in the form of logical array [0 0 1 0]
- compare 4th element of A{1} with A{3} all element, and sum the logical array, if its sum is greater than 0 it means that 4th element of A{1} exist in A{3}. apply and operation on the logical array given by step 2 with current output
- feed these logical index to A{2}(logical index)
separating element in cell according to some condition
1 vue (au cours des 30 derniers jours)
Afficher commentaires plus anciens
I have A
A={[237;238;241;243], [238;237;241;243;247], [241;237;238;243;247],...
[243;237;238;241;247;310],[247;238;241;243;310;381],[310;243;247],[381;247;310] }
I want to use this algorithm
First cell
- A{1}=[237;238;241;243]
- Put first and second element of A{1} in temp (temp=[237,238])
- Choose last element in temp, if it has only 2 element (238)
- Choose cell in A that the first element is 238 (A{2}=[238;237;241;243;247])
- Third element in A{1} is 241
- Does 241 belong to A{2}? yes
- So, we could add 241 to temp (temp=[237,238, 241])
- 4th element in A{1} is 243
- Does 243 belong to A{2} and A{3}? Yes ---> I have a problem to write a code for this part
- So, we could put 243 on temp (temp=[237,238, 241,243])
Result in this cell, temp =[237,238, 241,243])
0 commentaires
Réponses (1)
Mehmed Saad
le 18 Avr 2020
I will give you a hint for A{1}(4) with A{2} and A{3}
temp = [temp;A{2}(and((sum(A{3}==A{1}(4))>0),(A{2}==A{1}(4))))];
0 commentaires
Voir également
Catégories
En savoir plus sur Operators and Elementary Operations 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!