フィルターのクリア

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 Center および File ExchangeWorkspace 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