Extracting Matrix Elements using Defined Variable in Workspace
조회 수: 3 (최근 30일)
이전 댓글 표시
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
채택된 답변
Walter Roberson
2012년 6월 8일
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)
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Subplots에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!