undefine function : error
Show older comments
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 Comments
Swastik Sarkar
on 1 Jun 2023
Could you give the values of the function argument to reproduce the error ?
md sazzad
on 1 Jun 2023
Dyuman Joshi
on 1 Jun 2023
How do you run your code or call the function?
You need to provide inputs to the function to run it and get the output(s).
md sazzad
on 1 Jun 2023
md sazzad
on 1 Jun 2023
Image Analyst
on 1 Jun 2023
Did you forget to attach 'C:\Users\FX625040\Documents\Stage\Scripts Matlab\P0\capteur2125011.txt'?
If you have any more questions, then attach your data and code to read it in with the paperclip icon after you read this:
md sazzad
on 1 Jun 2023
Image Analyst
on 1 Jun 2023
If it says Y must be a column vector, then replace Y in line 131 with Y(:).
Stephen23
on 1 Jun 2023
Why did you define DEGREE as the sixth input argument, just to ignore that input argument and overwrite it with some unrelated value on the very next line?:
function [residus, Stat, coefficients] = Calcul_Coef_NEW(SN, type, table_pression_kPa, P, T, degree)
degree = input('Enter the degree of the polynomial: ');
md sazzad
on 1 Jun 2023
md sazzad
on 1 Jun 2023
Cris LaPierre
on 1 Jun 2023
You've also asked this question here: https://www.mathworks.com/matlabcentral/answers/1976639-facing-some-errors-during-doing-the-program-matlab?s_tid=srchtitle
Dyuman Joshi
on 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.
Answers (1)
Mathieu NOE
on 1 Jun 2023
0 votes
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
Categories
Find more on Automated Driving Toolbox in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!