Rows and Columns manipulation
9 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Adnan Khan
am 16 Mär. 2021
Kommentiert: Adnan Khan
am 17 Mär. 2021
Hey everyone. I have kind of tricky problem to solve.
I have three matrices, A with size of 1x1001 and is unique,
B is of size 1x119 (not unique) and
C is of size 1x1001 and is unique.
What I want is to see whether elements of B exists in C (repititions to be considered), if yes then they are at which indices in C? For example B(1,1) upto B(1,119) needs to be compared with the enitre C. All the values of B that exists in C are then stored in another matrix D along with the index of C. Here index is nothing but the number of column in which it occured, since there is only a single row.
Matrix D will contain the common value and the index at which it occured in C. Note: The values of matrices B and C needs to be compared upto two decimal places and ignore rest of it. For example value 50.234 in B is considered equal to value 50.239 in C. Here we will store 50.23 in matrix D along with its index at which it occured in C.
Now the final part,
Since D has a pair (value, index). Pick D's value and mulitply it with the value occuring at this index (specific number of column) in A. Do it for all values of D and store the result in E.
For example, if D(1,1) = (50.23, 4). Mulitply 50.23 with the value of A in 4th column.
0 Kommentare
Akzeptierte Antwort
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!