I need to find a way to plug in unknown values into a function I curve-fitted to known data.

9 次查看(过去 30 天)
I have a handful of 98x2 arrays that I'm treating as x and y values. The x values are unequally spaced, which is an issue in my case. My plan was to fit a curve to the x vs. y scatterplot using MATLAB R2020A's Curve Fitting app, utilizing the Smoothing Spline option. Once I fit the curve I planned to input my own custom (equally spaced) x-values into this fitted function and have the new y-values returned, which I would then build my new arrays out of.
I managed to fit the curve and it's accurate enough for what I'm using it for. However, I'm not sure what my next step is from here. I'm still a novice with MATLAB and learning a lot, but it's slow going. The fitted curve I generated doesn't appear to be a function that I can plug x values into, and I'm not certain how I would be able to tell the coordinates for each point. Is there a way for me to plug x-values into a fitted function such as this? Or rather an easier method that I've missed? Any and all help is very much appreciated, thank you!
  2 个评论
Torsten
Torsten 2022-3-23
编辑:Torsten 2022-3-23
If you had plain MATLAB code, we could help.
But I think you will have to read the documentation of the curve fitting tool to get your questions answered.

请先登录,再进行评论。

回答(2 个)

John D'Errico
John D'Errico 2022-3-23
编辑:John D'Errico 2022-3-23
This is not as hard as you make it seem. (Honestly, I tend not to use cftool at all. I just use fit.)
Look at the menu options. Under the fit menu, you should see the option: "Save to Workspace". Click on that. You will now see a popup.
The popup allows you to save your model to a variable in your MATLAB workspace. Pick whatever name you want.
You can now use that returned result to evaluate the function at any chosen point.

Steven Lord
Steven Lord 2022-3-24
You can generate code or export the fit to the workspace. Once you've done that you can evaluate it or perform other postprocessing on it.

类别

Help CenterFile Exchange 中查找有关 Get Started with Curve Fitting Toolbox 的更多信息

产品


版本

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by