Filter löschen
Filter löschen

undefine function : error

3 Ansichten (letzte 30 Tage)
md sazzad
md sazzad am 1 Jun. 2023
Beantwortet: Mathieu NOE am 1 Jun. 2023
Hello Dears, Here i got the one error undefined function 'degree' . can anyone say the solve? how i can get solution?
function [residus, Stat, coefficients] = Calcul_Coef_NEW(SN, type, table_pression_kPa, P, T, degree)
degree = input('Enter the degree of the polynomial: ');
table_pression_psi = table_pression_kPa * 0.145038;
% Fit the polynomial curve based on the specified degree
fitting_type = ['poly', num2str(degree)];
a='poly32';
[FCT_COR,GOF,OUTPUT] = fit([T, P], table_pression_psi, fitting_type);
% Calculate the residuals
residuals = table_pression_psi - FCT_COR(T', P');
residuals2=OUTPUT.residuals;
% Calculate the maximum and average residuals
Res_max = max(abs(residuals));
Res_moy = mean(abs(residuals));
SYNTH_RES{1, 1} = 'SN Capteur';
SYNTH_RES{2, 3} = 'P';
SYNTH_RES{1, 4} = 'Résidu max';
SYNTH_RES{1, 5} = 'Résidu moy';
SYNTH_RES{1, 6} = 'R²';
SYNTH_RES{1, 7} = 'Erreur standard (psi)';
SYNTH_RES{2, 1} = SN;
SYNTH_RES{2, 4} = Res_max;
SYNTH_RES{2, 5} = Res_moy;
%SYNTH_RES{2, 6} = NaN;
%SYNTH_RES{2, 7} = NaN;
SYNTH_RES{2,6}=GOF.rsquare;
SYNTH_RES{2,7}=GOF.rmse;
% Write the coefficients
coefficients = coeffvalues(FCT_COR);
for m = 1:length(coefficients)
SYNTH_RES{m+4, 1} = ['a', num2str(m-1)];
SYNTH_RES{m+4, 2} = coefficients(m);
end
SYNTH_RES{length(coefficients)+6, 1} = 'Pression banc (psi)';
SYNTH_RES{length(coefficients)+6, 2} = 'Pression banc (kPa)';
SYNTH_RES{length(coefficients)+6, 3} = 'Température (°C)';
SYNTH_RES{length(coefficients)+6, 4} = 'Ratio';
SYNTH_RES{length(coefficients)+6, 5} = 'Residu (psi)';
SYNTH_RES{length(coefficients)+6, 6} = 'Residu (kPa)';
SYNTH_RES{length(coefficients)+6, 7} = 'Pression corrigée (psi)';
SYNTH_RES{length(coefficients)+6, 8} = 'Pression corrigée (kPa)';
% Write the data (P reference, temperature, ratio, residuals, P0) in psi & kPa
for i = 1:length(table_pression_psi)
SYNTH_RES{length(coefficients)+6+i, 1} = table_pression_psi(i);
SYNTH_RES{length(coefficients)+6+i, 2} = table_pression_kPa(i);
SYNTH_RES{length(coefficients)+6+i, 3} = T(i);
SYNTH_RES{length(coefficients)+6+i, 4} = P(i);
SYNTH_RES{length(coefficients)+6+i, 5} = OUTPUT.residuals(i);
SYNTH_RES{length(coefficients)+6+i, 6} = OUTPUT.residuals(i)*6.894757;
SYNTH_RES{length(coefficients)+6+i, 7} = FCT_COR(T(i),P(i));
SYNTH_RES{length(coefficients)+6+i, 8} = FCT_COR(T(i),P(i))*6.894757;
%SYNTH_RES{length(coefficients)+6+i, 9} = residuals_p32(i);
%SYNTH_RES{length(coefficients)+6+i, 10} = residuals_p32(i) * 6.894757;
%SYNTH_RES{length(coefficients)+6+i, 11} = FCT_COR_p32(T(i));
%SYNTH_RES{length(coefficients)+6+i, 12} = FCT_COR_p32(T(i)) * 6.894757;
end
xlswrite(fullfile('.\results\Poly', strcat('SN', SN, '_synthese.xlsx')), SYNTH_RES, type);
residus = cat(2, residuals);
Stat(1, 1) = Res_max * 6.894757;
Stat(2, 1) = Res_moy * 6.894757;
%Stat(3, 1) = NaN;
%Stat(4, 1) = NaN;
%Stat(1, 2) = Res_max_p32 * 6.894757;
%Stat(2, 2) = Res_moy_p32 * 6.894757;
%Stat(3, 2) = NaN;
%Stat(4, 2) = NaN;
Stat(3,1)= GOF.rsquare;
Stat(4,1)= GOF.rmse*6.894757;
end
  13 Kommentare
Dyuman Joshi
Dyuman Joshi am 1 Jun. 2023
@Cris LaPierre, since (at that time) there was no activity on that post, and there was on this thread, I flagged that particular question.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Mathieu NOE
Mathieu NOE am 1 Jun. 2023
hello
I corrected all the bugs I could find - find my suggestions in the attached zip file
now the last point I cannot fully test is the fitting itself as I don't have the CF toolbox, but the "degree" issue is solved
all the best

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by