Creating Equation from Data

Hi, I'm a relatively new user to Matlab and have hit a roadblock. I'm currently trying to generate an equation with three independent variables (Discharge_prist, Q_prist, Ch_slope) and one dependent variable (Infill_vol), with the dependent variable being a function of the three independent variables. The only function I could find to do this was fitlm (see code below) but I'm not sure if it's the best to use here based on the low confidence that came with the equation it generated from the data. Is there anything else I can use? Thanks!
Also, I do not have permission to attach the data for the 4 variables here so I included a line of code that generated random numbers for each variable. I don't necessarily need the an equation right now that works with the data, just a way to generate one.
discharge_prist=rand(100,1);
q_prist=rand(100,1);
ch_slope=rand(100,1);
infill_vol=rand(100,1);
TBL=table(discharge_prist,q_prist,ch_slope,infill_vol);
mdl=fitlm(TBL,'infill_vol~discharge_prist+q_prist+ch_slope')

3 Comments

"Is there anything else I can use?" It really depends on the mathematical model of the process that generated the data. If the linear model does not seems to fit well, then you need to find the nonlinear equations of your process. An infinite number of nonlinear models can be created, so the question of which one to use really boils down to what is the mathematical model of the process that generated the data.
Hi Ameer, the data wasn't generated by a model. The data was measured in the field. I'm trying to create a model that relates the infill to the other three variables. The problem I've run into is just I'm not sure how to move further in Matlab past using fitlm to generate a model that does just that. Any recommendations will be useful!
Also, I tried using nlinfit but I wasn't sure what values I would need to use for beta0 (the initial values). https://nl.mathworks.com/help/stats/nlinfit.html
Derrick, in nlinfit(), beta0 is just the initial point for the optimization algorithm, and it is not a big issue. You can select it randomly or make an educated guess based on your model or data. The actual issue is, what is the formula for modelfun? You need to have an equation (with unknown parameters) that can relate the input observations to the output data. Then you can use the observed to find the unknown parameters.

Sign in to comment.

Answers (0)

Categories

Products

Release

R2019b

Tags

Asked:

on 21 Apr 2020

Commented:

on 21 Apr 2020

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!