Extracting Matrix Elements using Defined Variable in Workspace
5 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
Hello,
I'm trying to figure out if there is a way to identify a matrix element by passing through a variable string name inside the matrix call out as shown below:
System_Type= 2 <--- Variable Defined in Workspace
OutputMatrix = [8x8] <--- Matrix Defined in Workspace
OutputMatrix(1,1) <--- Normally Defining the value of the element in matrix
OutputMatrix('System_Type', 1) <--- How I would like to pass through variable "System_Type" and be able to extract the element of the matrix based on the string input value.
I'd appreciate it if anyone can provide guidance on this! Thanks Nima
0 Kommentare
Akzeptierte Antwort
Walter Roberson
am 8 Jun. 2012
No, or at least not with that syntax. You can use OutputMatrix(System_Type, 1)
If it is important that you pass the column name to another routine, then one way would be to pass it as an additional argument that you just use for whatever output purpose you need. Another way would be to construct a structure such as
colnames.ID_number = 1;
colnames.System_Type = 2;
colnames.Revision_Date = 3;
and then when you need to convert the field name to a value,
FieldName = 'System_Type';
[...]
OutputMatrix( colnames.(FieldName), 1)
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Subplots 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!