Info
Diese Frage ist geschlossen. Öffnen Sie sie erneut, um sie zu bearbeiten oder zu beantworten.
How to convert string to Matlab command line (function)?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentar
Antworten (0)
Diese Frage ist geschlossen.
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!