Effacer les filtres
Effacer les filtres

Info

Cette question est clôturée. Rouvrir pour modifier ou répondre.

How to convert string to Matlab command line (function)?

1 vue (au cours des 30 derniers jours)
John
John le 4 Août 2015
Clôturé : Stephen23 le 5 Août 2015
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.

Réponses (0)

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by