How to derive a function from 6 variables
6 views (last 30 days)
Show older comments
Flavio Lupoli
on 17 Nov 2022
Commented: Flavio Lupoli
on 20 Nov 2022
I have a nx1 column array A and a nx6 matrix B. Every line of the matrix B corresponds to a value in the same line of A. I want to "interpolate" these values (not sure if it is the right term) so that I obtain a function that puts in correlation every line of B with the correspondent line of A (so basically, a function f of six variables). Which Matlab function should I use?
1 Comment
VBBV
on 17 Nov 2022
Search in the google god. You will find many results suggesting which function to use. Or use the help centre of matlab website to find more info about those functions.
Accepted Answer
John D'Errico
on 17 Nov 2022
Edited: John D'Errico
on 17 Nov 2022
Knowing which function to use, given 6 independent variables is terribly difficult to know. If you lack knowledge of a good nonlinear form, it is often the case you want to use simple, LOW order polynomial models. A linear model would be a start, so linear in 6 variables. Even there you will have 7 parameters to estimate. (Don't forget the constatn term.)
That fit requires nothing more than:
% coeffs = [B,ones(n1)]\A;
So the constant term will be the last coefficient in that list.
I don't know how much data you have, but that is where I would start. Beyond that point, beware, as there lie dragons. Far too many people want to fit high order polynomials. And that is often a bad idea. At most, I might suggest a 2nd order polynomial model. You could use my polyfitn, as found on the file exchange. But as I said, far too many abuse this sort of thing, not realizing how difficult polynomials can get in high dimensions.
If you find the fit is inadequate with the linear polynomial, AND you have sufficient data to build a neural net model, I would go in that direction. Of course, it would require you learn to use those tools. You might start looking here:
help fitnet
More Answers (0)
See Also
Categories
Find more on Multidimensional Arrays in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!