An apostrophe, or rather a single quote as it is called, in a string can be accomplished by doubling it, like in:
More importantly, you do not want to use eval at all, by designing your variables a little bit more clever using, e.g., cell arrays or structs.
B(1).values = sinc(x).*sinc(y);
B(2).values = sinc(2x).*sinc(2y);
for k = 1:numel(B)
filename = sprintf('B_%d.bmp',k)
imwrite(B(k).values, filename)
end
This away you avoid all the complications induced by eval ...
2 Comments
Jos (10584) (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/119416-how-do-i-use-eval-function-when-the-sentence-has-apostrophe-in-it#comment_199086
Stephen Cobeldick (view profile)
Direct link to this comment
https://www.mathworks.com/matlabcentral/answers/119416-how-do-i-use-eval-function-when-the-sentence-has-apostrophe-in-it#comment_514770
Sign in to comment.