(this is the key part I am struggling with, would I say something like location1 = A[1,1] ? I don't need the data in that position of the matrix I need the actual position ie: the 1 and 1. I want the input of the location codes to give
me a matrix location.)
Now, some other answers to your questions:
- alpha numeric code into a matrix:
assuming you need to store your code as a string and later do a
string comparison, it's probably easiest to create a cell array.
matrices can store strings, but only one character per location. a =
'hello' is actually a(1,1) = 'h', a(1,2) = 'e', etc. All strings need
to be the same length, and you'd have to do some 3-dimensional
trickery to store your strings in a matrix. Better is to use a cell.
A cell array can hold arbitrary things in each location. Cells are
(generally) referenced with curly braces. eg.,
>> b{1,1} = 4;
>> b{1,2} = 'hello';
>> b{2,1} = 'world';
>> b{2,1} = false;
>> b
b =
{
[1,1] = 4
[2,1] = world
[1,2] = hello
[2,2] = 0
}
So, you should be able to create an array with each cell location
containing your bin name strings. Learn more about using and accessing
cells here:
https://www.gnu.org/software/octave/doc/v4.2.0/Basic-Usage-of-Cell-Arrays.html
https://www.gnu.org/software/octave/doc/v4.2.0/Creating-Cell-Arrays.html (I will definitely give this a look, thank you)
Not really sure what you mean by 'multiple codes per matrix location' (In the warehouse there are multiple bins that will correspond to a location on the matrix, so I will have to enter multiple bin locations for each matrix location. Eg A(1,1) = ae-02-32 ;
ae-02-33 ; ae-02-34. I don't even know if this is possible. And to give you an idea there are 57 000 bins.)
- spitting out a location after entering a code:
first what do you mean by 'entering a code'? are you prompting the
user to type in two codes/locations? do you know how to do that? (Ideally the program should draw the bin locations from our warehouse management system, it creates a picking slip that sends a picker to each bin location, a location is shown as ae-02-33 for
example. I have some experience with the fetch data functions but am not sure what format the WMS will provide data.)
Assuming you do, and you store the users input as a string, you will
then need to do a string comparison with those in the cell array you
created above. (note the command below will fail if every cell
location isn't a string)(I will be sure the data pulled in will be stored a string and all the data will be in the same format as ae-02-33.)
>> b{1,1} = 'world';
>> b{1,2} = 'hello';
>> b{2,1} = 'hello';
>> b{2,2} = 'world';
>> strcmp(b,'hello')
ans =
0 1
1 0
OR
>> find(strcmp(b,'hello'))
ans =
2
3
you can then use the location(s) in whatever way you find useful. (I want to use the difference in the locations in the matrix as a unit measure eg: I know the distance between lateral bins is 3m and longitudinal bins is 5m. So if ae-02-33 is at A(1,1) and
af-02-35 is at A(2,3) the movement is abs(1-2) longitudinal and abs(1-3) lateral so 1 and 2. Therefore distance walked is 1×5 + 2×3 = 11.)
I don't know if I am making this more complicated than necessary.