Using Matfile() in combination with a variable
조회 수: 1 (최근 30일)
이전 댓글 표시
I reference a Matfile and to access its entries using a variable:
a = 'variablefrommat';
m = matfile('myMat.mat');
x = m.a
This results (obviously) in Matlab searching the Matfile for 'a'. In my case this error occurs:
'a' does not exist in 'myMat.mat'.
Is there a way to interpret 'a' as the variable?
댓글 수: 0
채택된 답변
추가 답변 (1개)
Geoff Hayes
2018년 11월 21일
Jan - if you know the name of the variable that you want to reference then why are you setting this to its own variable? What are you trying to accomplish here?
x = getfield(m,a)
which will return the expected result...but do you need to do it this way?
참고 항목
카테고리
Help Center 및 File Exchange에서 Workspace Variables and MAT-Files에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!