Borrar filtros
Borrar filtros

how run generated code from apps

3 visualizaciones (últimos 30 días)
roberto
roberto el 16 de Feb. de 2023
Movida: Voss el 16 de Feb. de 2023
hello everybody
I've generated a simple code from curve fitting app by export code toolbar.
I've tried to past it in command windows but doesn't work.
function [fitresult, gof] = createFit(close)
%CREATEFIT(CLOSE)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
% Y Output: close from eurusd
% 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 16-Feb-2023 15:06:52
%% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData( [], close );
% Set up fittype and options.
ft = fittype( 'poly1' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'close', 'untitled fit 1', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
ylabel( 'close', 'Interpreter', 'none' );
grid on

Respuesta aceptada

Kevin Holly
Kevin Holly el 16 de Feb. de 2023
Editada: Kevin Holly el 16 de Feb. de 2023
You would want to save the code as a .m file. Then you can call the function with this line:
createFit(close)
Where close is your input
For example:
data = rand(14,1);
createFit(data)
ans =
Linear model Poly1: ans(x) = p1*x + p2 Coefficients (with 95% confidence bounds): p1 = 0.01584 (-0.02285, 0.05453) p2 = 0.4963 (0.1669, 0.8258)
function [fitresult, gof] = createFit(close)
%CREATEFIT(CLOSE)
% Create a fit.
%
% Data for 'untitled fit 1' fit:
% Y Output: close from eurusd
% 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 16-Feb-2023 15:06:52
%% Fit: 'untitled fit 1'.
[xData, yData] = prepareCurveData( [], close );
% Set up fittype and options.
ft = fittype( 'poly1' );
% Fit model to data.
[fitresult, gof] = fit( xData, yData, ft );
% Plot fit with data.
figure( 'Name', 'untitled fit 1' );
h = plot( fitresult, xData, yData );
legend( h, 'close', 'untitled fit 1', 'Location', 'NorthEast', 'Interpreter', 'none' );
% Label axes
ylabel( 'close', 'Interpreter', 'none' );
grid on
end
  2 comentarios
roberto
roberto el 16 de Feb. de 2023
Movida: Voss el 16 de Feb. de 2023
Tks very much
Kevin Holly
Kevin Holly el 16 de Feb. de 2023
Please accept the answer if this satisfies your questions. Thanks.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Fit Postprocessing en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by