MATLAB: Symbol from string [2]

stringsymsymbolicsyms

a='name'
syms (a)
this code generates a symbol called 'name'. If I write a function, I don't know the string before I use it, so how can I use the symbol 'name' (like symbol) into the function?
i.e
function [A]=f(a)
a='name';
syms (a)
c=cos(name);
s=sin(name);
A=c+s;
In the output I want a symbolic expression A=cos(name) + sin(name).
Thank you a lot for you answer. Pietro Rossi

Best Answer

I would try
function [A]=f(a)
%a='name'; %I presume this will be passed in
syms (a)
c=cos(a);
s=sin(a);
A=c+s;
Related Question