How to use vectors inside the fittype function
5 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Hello,
I am using the fit function in order to take experimental data and fit it with an expression. The expression that I need to use also uses multiplication of variables which are vectors, within the expression. The problem is that the fittype is a string, which only "knows" the independent variable and the coefficients, as far as I understand. So it does not work, and I dont know how to send these vectors into the expression so fittype can use it. It is best to give a simplified example:
lets say I have only two data points (x1,y1),(x2,y2), and I have another vector, V, which has two elements in it. Mathematically, the expression I want to fit is A1*V./x ( where x is (x1,x2) ), and as a function this will give an answer which is a vector with 2 elements. But the fittype string would be 'A1*V./x' and the symbol V has no meaning since it is not the dependent variable x, and it is not a coefficient.
how can I solve this?
Thank you, Itai.
0 comentarios
Respuestas (2)
Elizabeth Reese
el 4 de Dic. de 2017
You can do this by supplying an anonymous function for the expression in fittype instead of a string.
For example
g = fittype( @(a1,v,x) a1*v./x, 'problem', 'v' );
f = fit(xdata,ydata,g,'problem',V)
0 comentarios
Ver también
Categorías
Más información sobre Linear and Nonlinear Regression en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!