## Warning: Support of strings that are not valid variable names or define a number will be removed in a future release. To create symbolic expressions, first create symbolic variables and then use operations on them.

### Muhendisleksi (view profile)

on 29 Oct 2017
Latest activity Edited by Walter Roberson

### Walter Roberson (view profile)

on 29 Oct 2017
What does this warning mean? And how can I solve the problem?

Birdman

on 29 Oct 2017
Share the code
Muhendisleksi

on 29 Oct 2017
Muhendisleksi

### Muhendisleksi (view profile)

on 29 Oct 2017
for example:
turev_s('x^2+y^2*sin(t)','t','x,y,t',[1 2 30])
I get an alert when I make the above example. How can I solve this problem?
Can not I show the value of "s" as fprintf?
function turev_s(x, y, d, r)
f = sym(x);
n = length(symvar(f));
if n == 1
s = diff(f,y);
pretty(s)
if r ~= 0
sonuc = double(subs(f,{d},{r}));
end
elseif n == 2
s = diff(f,y);
pretty(s)
if r ~= 0
sonuc = double(subs(f,{d},{r}));
end
elseif n == 3
s = diff(f,y);
pretty(s)
if r ~= 0
sonuc = double(subs(f,{d},{r}));
end
end
fprintf('Sonuc = %.4f\n',sonuc);
end

### Tags ### Walter Roberson (view profile)

on 29 Oct 2017
Edited by Walter Roberson

### Walter Roberson (view profile)

on 29 Oct 2017

In versions before R2017b, the only way to convert a character vector expression into a symbolic expression was to use sym() on the character vector. For whatever reason, Mathworks has chosen to say that is Not Good, and has been warning for several releases that the ability to sym() an expression will be going away.
The expectation is that outside of that routine the user would have done
syms x y t
f = x^2+y^2*sin(t);
turev_s(f, t, [x y t], [1 2 30])
and that the code would be,
function turev_s(x, y, d, r)
n = length(symvar(f));
if n == 1
s = diff(f,y);
pretty(s)
if any(r)
sonuc = double(subs(f, d, r));
end
elseif n == 2
s = diff(f,y);
pretty(s)
if any(r)
sonuc = double(subs(f, d, r));
end
elseif n == 3
s = diff(f,y);
pretty(s)
if any(r)
sonuc = double(subs(f, d, r));
end
end
fprintf('Sonuc = %.4f\n',sonuc);
end
... which has an error if there are no symbolic variables or more than 3 symbolic variables, and does the same thing in each of the cases. It also has a bug for the case where the r are all 0. It could be rewritten as
function turev_s(x, y, d, r)
s = diff(f, y);
sade = simplify(s) %no semi-colon -- want it to display
pretty(s) %no semi-colon -- want it to display
if any(r)
sonuc = double(subs(f, d, r));
fprintf('Sonuc = %.4f\n',sonuc);
end
As of R2017b, Mathworks added str2sym() to convert character vectors to symbolic expressions. The expressions need to be in MATLAB syntax -- the sym() version expected the expressions to be in MuPAD syntax (which might be why they want to get rid of it.)