# how can i find a fuction which define input and output of a system?

10 views (last 30 days)

Show older comments

##### 0 Comments

### Accepted Answer

Shoaibur Rahman
on 17 Jan 2015

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 Comments

### More Answers (0)

### See Also

### Categories

### Community Treasure Hunt

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

Start Hunting!