Effacer les filtres
Effacer les filtres

How to access table with eval?

6 vues (au cours des 30 derniers jours)
Y. J.
Y. J. le 25 Juil 2018
Réponse apportée : Jan le 25 Juil 2018
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 commentaires
Stephen23
Stephen23 le 25 Juil 2018
"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 le 25 Juil 2018
@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.

Connectez-vous pour commenter.

Réponses (1)

Jan
Jan le 25 Juil 2018
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.

Catégories

En savoir plus sur Workspace Variables and MAT-Files dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by