필터 지우기
필터 지우기

Four input parameters and one output parameter, try to model or fit the input and output values

조회 수: 10 (최근 30일)
Hi, I am quite new to Matlab. I have this problem to develop a model to fit the data between multiple inputs and output. What I need to do is to find a suitable model y=f(x1,x2,x3,x4). I need to try different models, linear or non-linear, or using other tools like neural network. I can find the curve fitting to two parameters (y=f(x1,x2), but for four inputs, I have some problems. Does anyone has a clue? Thanks

채택된 답변

Star Strider
Star Strider 2015년 2월 11일
Yes. If you have more than one independent variable, concatenate all of them in a matrix (I prefer they be column vectors), then refer to them by their columns within the model function you want to fit.
For instance, if you want to fit: y = a*x1^2 + b*exp(c*x2), create your ‘x1x2’ matrix (or whatever you want to call it) as:
x1x2 = [x1 x2];
then in the function you want to use to fit your data, using a single vector ‘b’ for your parameter vector:
% b(1) = a, b(2) = b, b(3) = c
f = @(b,x) b(1).*x1x2(:,1).^2 + b(2).*exp(b(3).*x1x2(:,2));
and the call to nlinfit (for example) would then be:
B = nlinfit(x1x2, y, f, B0);
That is how I do it, and it works. You would simply expand what I call ‘x1x2’ here to include your four independent variable value vectors.
(Note: all the code here is untested, but then it’s also all hypothetical.)
  댓글 수: 6
Wu Ying
Wu Ying 2015년 2월 12일
Sorry to bother, I have more than 9 b, it says b is only allowed 9 numbers, b[1-9], how can I do it?
Star Strider
Star Strider 2015년 2월 12일
I do not understand. What function does not allow you more than 9 parameters?

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Get Started with Curve Fitting Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by