in Matlab I have several database records stored in a matrix DataMatrix. Each row of the matrix is ββa record, and each column is a value of a record property. To make the program understandable for each column DataMatrix, I defined a variable name that explains which property is associated with the column, that is:
ColApple = 1;
ColOrange = 2;
ColLemon = 3;
...
I have about columns 50for a name.
My problem is that the values ββin DataMatrixare used in different functions, and I would like to always use the column name to work with the data in DataMatrix. So I have to be shared between different values of functions ColApple, ColOrange, ColLemon,...
So far I have been thinking about two possible approaches:
- Creating global column names
Define a function that returns values ββfor the column name, namely:
[ColApple, ColOrange, ColLemon, ... ] = getColNames
I would avoid a global solution because I think it is dangerous, and also because I would like the column name to be constant, if possible. The second approach is better, but since I have columns 50, I donβt know if there is a good idea for the function to return 50different values ββ(this is also difficult to maintain in my opinion).
Does anyone have a more reliable or supported approach to solve this problem? I am sure that I am not the first to deal with this, but I could not find a solution.
source
share