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.
    4 vues (au cours des 30 derniers jours)
  
       Afficher commentaires plus anciens
    
What does this warning mean? And how can I solve the problem?
3 commentaires
Réponses (1)
  Walter Roberson
      
      
 le 29 Oct 2017
        
      Modifié(e) : Walter Roberson
      
      
 le 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);    
    sade = simplify(s)
    pretty(s)
    if any(r)
        sonuc = double(subs(f, d, r));
    end
elseif n == 2
    s = diff(f,y);
    sade = simplify(s)
    pretty(s) 
    if any(r)
        sonuc = double(subs(f, d, r));
    end
elseif n == 3
    s = diff(f,y);
    sade = simplify(s)
    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.)
0 commentaires
Voir également
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!


