how can i find a fuction which define input and output of a system?
조회 수: 5 (최근 30일)
이전 댓글 표시
i have a system and i put some values in and get its output. for instance y=f(x) i know the values of y and x .i get y by monte carlo simaltion numerically now ,how can i find a function which is close to f ? what command can i use? i need to use the function f in another m.file
댓글 수: 0
채택된 답변
Shoaibur Rahman
2015년 1월 17일
Use:
p = polyfit(x,y,n) % n is degree of polynomial, use a value that best fit your data
To check the fitting:
y_fit = polyval(p,x);
plot(x,y, x,y_fit)
If you are satisfied with your fitting, then your function will be:
f = p(1) + p(2)*x + p(3)*x.^2 + p(4)*x.^3 + ... + p(n+1)*x.^n
And, you can write this function in a separate m-file
댓글 수: 4
Image Analyst
2015년 1월 17일
You would never fit a 13th order polynomial. Have you ever seen what happens between and after your training points when you do that? They go haywire with enormous oscillations!
You should have some idea of the type of function you want to fit if you're looking for an analytical formula, like a polynomial or something. I have no idea what it might be because you're not sharing a plot of your data, or even the data itself so we're left to guess (or not even bother to answer which I'm sure many did).
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Uncertainty Analysis에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!