MatLab - de-char a char

조회 수: 1 (최근 30일)
Lucas
Lucas 2012년 5월 31일
You read that right, this is probably the oddest question that I ever asked, but I just want to know if I can de-char a char. I don’t think it’s possible but I thought someone might have a nifty way to get me what I want.
So I have Java and MatLab connected via a socket and I have a global variable in a Simulink model that I want to send to java from an ‘m’ file. Java requests which global variable it wants and MatLab returns it. If I hardcode the global I want everything works wonderfully. But if I parse the name I want from a string it returns a string to java. My code looks like:
Test = regexp(char(remain), ';(?<varname>\w*)', 'names');
out.println(Test(1).varname);
out.println(Variable); - what it does / returns a string
out.println(Variablle); - what I need / return value of sim block
Test(1).varname gives me that name I want but it comes out as: ‘Variable’ which is not what I want. I didn’t know if there was any way I could get rid of the ‘’ around the variable name I need. Thanks.

채택된 답변

Walter Roberson
Walter Roberson 2012년 5월 31일
  댓글 수: 7
Oleg Komarov
Oleg Komarov 2012년 5월 31일
@Lucas: eval() is the painful beast. It teaches bad programming habits. That's what I was refering to.
Usually questions involving eval() as potential answer come in very different forms and almost all the time eval() is not the best answer.
Walter Roberson
Walter Roberson 2012년 5월 31일
Odd, I tested just now and the URL points to the FAQ section I intended, 3 questions further up than the dynamic filename one.

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by