how to use single quotes in eval

so, the initial command is: plot(xtmc,ftmc,'LineWidth',3) Now, If I use "eval" the command would be: eval(['plot(xtmc,ftmc,', ''LineWidth'', ',3') (which doesn't work) So, is there any way to fix this question?
Also, I found that many people didn't recommend using "eval", so, is there any alternative function I can use?

2 Comments

What are you doing that eval seems like something you might want to do?
Stephen23
Stephen23 on 13 May 2018
Edited: Stephen23 on 13 May 2018
"I found that many people didn't recommend using "eval", so, is there any alternative function I can use?"
The problem is not that eval is faulty and therefore another function is better, the problem is what people do with it. So far you have not told us why you need to use eval or what you are trying to do, so there is not really any more specific advice that we can give you apart from "most likely your approach is very inefficient and using eval is not a good solution".

Sign in to comment.

Answers (1)

Tags

Asked:

on 13 May 2018

Edited:

on 13 May 2018

Community Treasure Hunt

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

Start Hunting!