curve fitting toolbox code

조회 수: 3 (최근 30일)
saeed
saeed 2021년 1월 18일
댓글: dpb 2021년 1월 19일
Hi everybody
I fitted my curve which goes over these two points(0,0) and(1,1) in matlab fitting toolbox, i want to extract what will be the y if x=2 in m.file.
How to convert toolbox to code and create function in which when I import x=2 it shows y=2 .
I don't know why the generation code is a function of x & y not only x.
Can anybody help me?
thanks
  댓글 수: 3
saeed
saeed 2021년 1월 19일
thanks for your reply but as i didn't understand what you said I make my question clear:
these are my point:
x=[1 2]
y=[2 4]
I open cftool, select x for xdata and y for ydata, then from the fit menu I click on "save to workspace" and save the 3 fits, now if I type fittedmodel(3) in the command section, it shows output=6, but if I close matlab then it doesn't show output 6, what should I do to call fittedmodel(3) from another m.file?
thanks
dpb
dpb 2021년 1월 19일
You have to somehow get the fit object into the correct context; functions have their own context and so a new function doesn't know anything about the model you saved into the workspace.
Three basic options --
  1. If you have the data available, build the model from the data in the function having used the fit tool to find the class of model that is satisfactory, or;
  2. SAVE the fit object you created in the fit tool to a .mat file and load it back within the function, or
  3. pass the object to the function from a context in which it does exist.
The tool can also build an m-file which will regenerate the model but it also either must read in the data again or have it stored internally.

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

답변 (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