Info
此问题已关闭。 请重新打开它进行编辑或回答。
How to convert string to Matlab command line (function)?
1 次查看(过去 30 天)
显示 更早的评论
We want to make a text line into a function with variable length according to the situation:
functext = '';
for nt =1:N,
functext = sprintf('%s @(c,xdata) sin(c(%d)*xdata+c(%d))',functext,1+2*(nt-1),2*nt);
end
This is to form a funlist with structure as:
funlist = {1, @(c,xdata) sin(c(1)*xdata+c(2)), @(c,xdata) sin(c(3)*xdata+c(4)), @(c,xdata) sin(c(5)*xdata+c(6)) ... };
for use with a very good tool "fminspleas" from "matlab-file-exchange" with a linear summation of a series sinusoidal functions:
y = a0 + a1*sin(c1*x+c2) + a2*sin(c3*x+c4) + a3*sin(c5*x+c6) + ...;
How to convert the functext into funlist? eval? str2fun?
Thanks.
1 个评论
回答(0 个)
此问题已关闭。
另请参阅
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!