Renaming the variabel while Symbolic to function handle conversion with matlabFunction
显示 更早的评论
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.
采纳的回答
更多回答(1 个)
James Tursa
2022-6-8
You could keep your existing code and create another function handle:
funcv = @(A,xdata,ydata)func(A(1),A(2),xdata,ydata)
3 个评论
Saravanakumar Dharmaraj
2022-6-8
James Tursa
2022-6-8
编辑:James Tursa
2022-6-8
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
2022-6-8
类别
在 帮助中心 和 File Exchange 中查找有关 Numerical Integration and Differentiation 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!