Renaming the variabel while Symbolic to function handle conversion with matlabFunction
Ältere Kommentare anzeigen
I do have the symbolic equation which is given as

A5, A1,
(xdata and ydata) are the only variables and rest of them are constants.
Objective: To convert symbolic into function handle with replacing scalar variable (A1, A5) as a Vector A (A(1), A(2)).
When I use matlabFunction(F1),
F1d=vpa(subs(F1,[k m_canti B L Gap rho mu omega],[k_val m_canti_val B_val L_val Gap_val GWM_density(1) xdata ydata]),6)

func = matlabFunction(F1)
I am getting the result as below
func =
@(A1,A5,xdata,ydata)ydata.*-1.0-1.0./sqrt(A5.*3.987559999999988e-1+A1.*sqrt((xdata.*9.968899999999994e+2)./ydata).*2.26274169979699e-4+1.073920000000006e-3).*4.260164316079795
Since I am going to use this function for curve fitting I want A1, A5 to be renamed as A(1) and A(2). Basically I want to introduce a vector A in the above function handle.
I have gone through the documentation of matlabFunction(), Still I couldn't able to understand how to do what I want to achieve. I would be so grateful, if this problem got solved.
Thank you.
Akzeptierte Antwort
Weitere Antworten (1)
James Tursa
am 8 Jun. 2022
You could keep your existing code and create another function handle:
funcv = @(A,xdata,ydata)func(A(1),A(2),xdata,ydata)
3 Kommentare
Saravanakumar Dharmaraj
am 8 Jun. 2022
James Tursa
am 8 Jun. 2022
Bearbeitet: James Tursa
am 8 Jun. 2022
Please show the code you are currently using (or a small example that exibits this behavior) for creating the function handle. You want some parts of it to be vectors that are currently individual variables? What parts of this building process do you want "automated"? Etc.
Saravanakumar Dharmaraj
am 8 Jun. 2022
Kategorien
Mehr zu Numerical Integration and Differentiation finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!