フィルターのクリア

Get my X and Y values from curve fitting tool

77 ビュー (過去 30 日間)
Shree Pannaga
Shree Pannaga 2023 年 1 月 13 日
編集済み: Matt J 2023 年 1 月 13 日
First of all i´m completely new on matlab so forgive me if this is a dumb question... I had a curve fitting problem for my project and curve fit was completed using using custom fit equation and got a very nice fit.
The equation used for curve fitting was Y=1-((1-(X)^B)^A). R2 value I got around 95% and the co-effiecent value I got was A =0.6454 (0.5501, 0.7407) and B =0.1164 (0.09036, 0.1425)
Now I need the values of the X axis and Y axis Data of the fitted curve so I wonder if there is a fast and simple way to get them.
Please reply to my question immedieately. Any help will be appriciated.
  2 件のコメント
Mathieu NOE
Mathieu NOE 2023 年 1 月 13 日
hello
it would help if you would share your code
Shree Pannaga
Shree Pannaga 2023 年 1 月 13 日
function [fitresult, gof] = createFit(CycleRatio, Damage)
%CREATEFIT(CYCLERATIO,DAMAGE)
% Create a fit.
%
% Data for 'untitled fit 5' fit:
% X Input: CycleRatio
% Y Output: Damage
% Output:
% fitresult : a fit object representing the fit.
% gof : structure with goodness-of fit info.
%
% See also FIT, CFIT, SFIT.
% Auto-generated by MATLAB on 13-Jan-2023 20:08:19
%% Fit: 'untitled fit 5'.
[xData, yData] = prepareCurveData( CycleRatio, Damage );
% Set up fittype and options.
ft = fittype( '1-(1-(x)^B)^A', 'independent', 'x', 'dependent', 'y' );
opts = fitoptions( 'Method', 'NonlinearLeastSquares' );
opts.Display = 'Off';
opts.Lower = [-1 -1];
opts.StartPoint = [0.779167230102011 0.530797553008973];
opts.Upper = [1 1];
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft, opts );
% Plot fit with data.
figure( 'Name', 'untitled fit 5' );
h = plot( fitresult, xData, yData );
legend( h, 'Damage vs. CycleRatio', 'untitled fit 5', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
xlabel( 'CycleRatio', 'Interpreter', 'none' );
ylabel( 'Damage', 'Interpreter', 'none' );
grid on

サインインしてコメントする。

回答 (1 件)

Cameron
Cameron 2023 年 1 月 13 日
編集済み: Cameron 2023 年 1 月 13 日
If you are using the Curve Fitting App, go to Export in the top right and select Export to Workspace. Then select OK, and your information should be in the fittedmodel variable.
fittedmodel.p1
fittedmodel.p2
%or
fittedmodel.A
fittedmodel.B
  2 件のコメント
Shree Pannaga
Shree Pannaga 2023 年 1 月 13 日
Hello Mr. Cameron, Thank you for the answer. But in my problem I am getting the variable values A and B oncee the fitting is created. My problem is I want to get the values of X axis and Y axis data after I finishes the fitting.
Matt J
Matt J 2023 年 1 月 13 日
編集済み: Matt J 2023 年 1 月 13 日
The fitting process does not generate any X,Y data post-fit. However, the fittedmodel object that you export can be used to evaluate the fitted curve at any X values you wish. For example, if xdata,ydata are the data that you used to perform the fit, then you could do,
X=linspace(min(xdata), max(xdata),1000);
Y=fittedmodel(X)

サインインしてコメントする。

カテゴリ

Help Center および File ExchangeFit Postprocessing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by