|
Hi, all. I would very much appreciate some advice.
I would like to be able to specify a symbolic function in a dialog box:
syms xi;
prompt = {'Enter function:'};
dlg_title = 'Function input';
num_lines = 1;
def = {'sin(xi)'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
f(xi)=answer{1};
Error using sym/subsindex (line 1555)
Indexing input must be numeric, logical or ':'.
And when I remove the variable it gives me f=sin(xi) just fine but apparently just as a 'char' class object:
syms xi;
prompt = {'Enter function:'};
dlg_title = 'Function input';
num_lines = 1;
def = {'sin(xi)'};
answer = inputdlg(prompt,dlg_title,num_lines,def);
f=answer{1};
>> f
f = sin(xi)
>> f(pi/2)
Subscript indices must either be real positive integers or logicals.
>> class(f)
ans = char
Is there a way to type a function into a dialog box and have it function in the script properly?
>>symfun(f) was unsuccessful at converting f from 'char' to 'symfun'.
Thanks in advance.
Rebecca
|