Hi Tomas,
From the example I figured out that you want to determine the index of a given value in a matrix. To solve this problem, you can use the concept of hashing. That means you can store the value and the index in a map. For example, if there is a 2D matrix:
1 9 7
11 4 2
Then the map will look like:
1 -> "1,1"
9 -> "1,2"
7 -> "1,3"
11 -> "2,1"
4 -> "2,2"
2 -> "2,3"
You can store the above data and extract the information as per the requirement. MATLAB does not provide any data structure for this purpose. You can use Java collections in MATLAB by importing them. Please refer to the below example for the same.
import java.util.HashMap
% Step 1: Create a Java HashMap
hashMap = java.util.HashMap();
% Step 2: Populate the HashMap with key-value pairs
hashMap.put(1,'1,1');
hashMap.put(11,'2,1');
% Step 3: Retrieve values from the HashMap
index = hashMap.get(11);
% Display the retrieved values
disp(['Index for 11: ', index]);
You can change the format of the data being stored in the map as per the requirement. I hope this helps!
Thank you.