MYM and fields name '_key'

With many thanks again to the author of MYM! We use it heavily in a production environment on a number of Matlab licenses and machine types.
Recently an issue has cropped up that cannot have affected us only, although we get no matches on searches at this site.
One of our main (and elderly) tables uses a Primary Key (auto-incrementing) with the name '_key'. This seems to be a common database technique. However, Matlab does not allow variable names that start with an underscore! Thus the MYM query works perfectly and returns the struct with member _key in it. And Matlab displays this variable ok, ie:
quakeDump =
_key: [2179x1 double]
time: {2179x1 cell}
latitude: [2179x1 double]
longitude: [2179x1 double]
Yet any attempt to operate on this field gets us:
??? Error: File: blah.m Line: 42 Column: 11
The input character is not valid in MATLAB statements or expressions.
There must be some simple work-around we are missing? So far though, the only ways out we see include:
1. Rename field from '_key' to 'key", etc. Problem: impacts hundreds of lines of existing code, and we'll never hear the end of it!
2. Revert to our pre-MYM technique and use a PERL-DBI script to access the database. Problem: Slower than frozen molasses!
Does anybody have any suggestions? THANKS ALOT!
- Clark

댓글 수: 1

Walter Roberson
Walter Roberson 2012년 5월 17일
Jan has a work around for this, but I never remember the keywords for searching for it.

댓글을 달려면 로그인하십시오.

 채택된 답변

Jan
Jan 2012년 5월 17일

0 개 추천

You can access ugly fieldnames using "dynamic fieldnames":
S.('_key')
or
key = '_key';
S.(a)

댓글 수: 1

Clark
Clark 2012년 5월 17일
Jan!
Thanks alot! That FIXED it. Since I can't thank you personally, then the best I can do is to say 'nice pic!'

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

태그

질문:

2012년 5월 17일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by