필터 지우기
필터 지우기

How to access table with eval?

조회 수: 6 (최근 30일)
Y. J.
Y. J. 2018년 7월 25일
답변: Jan 2018년 7월 25일
Hey guys,
i am creating a table with
eval([N '= table']);
Now i want to write data in that table with smth. like:
eval([N'.Torque1cNm = cell2mat(raw(:,1)']);
But i get the error massage
Error: This statement is incomplete.
I don´t know where my mistake is.
I hope u can help me.
Thanks in advance
  댓글 수: 4
Stephen23
Stephen23 2018년 7월 25일
"I don´t know where my mistake is."
Your code is missing one closing parenthesis. Of course if you had not used awful eval then MATLAB's inbuilt code checking would have highlighted this error and made it easy to fix, but because you decided to use eval you have forced yourself into writing buggy code that is harder to debug (because none of the static code checking tools work). This is one of the reasons why the MATLAB documentation and all MATLAB experts advise against doing what you are doing:
Jan
Jan 2018년 7월 25일
@Y.J.: Please do not cross-post a question in multiple forums, because this wastes the time of the ones who post answers, when they write something, which has been posted already elsewhere. If you have a really good reason for cross-posting, please add links to the other threads in each forum. Thanks.

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

답변 (1개)

Jan
Jan 2018년 7월 25일
While the suggestions to avoid eval are the way to go, the actual problems are:
eval([N'.Torque1cNm = cell2mat(raw(:,1)']);
^ ^
The first is interpreted as transposition, and at the second mark a closing parenthesis is missing.
eval([N, '.Torque1cNm = cell2mat(raw(:,1))']);
But again: Don't do this. It is drilling a hole in your knee.

카테고리

Help CenterFile 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!

Translated by