how to convert this code exposal to linear and how to find mape

8 Ansichten (letzte 30 Tage)
andrew moisidi
andrew moisidi am 29 Mai 2021
Bearbeitet: Walter Roberson am 11 Mär. 2025
function [a,g0] = getExpontialModel(f)
A = zeros(1,length(f)-1);
G_0 = zeros(1,length(f)-1);
for i=2:length(f)
if f(i-1) ~= 0
A(i-1) = f(i)/f(i-1);
else
A(i-1) = 1;
end
end
a = median(A); %more robust than mean function
for i=1:length(f)-1
G_0(i) = f(i)/a^i;
end
g0 = median(G_0);%more robust than mean function

Antworten (1)

Rahul
Rahul am 11 Mär. 2025
In order to convert the exponential model to a linear model, consider using the logarithmic transformation. For this 'log' function can directly be used.
In order to fins the MAPE (Mean Absolute Percentage Error), a direct function is not availble in MATLAB in R2017b, however, it can be calculated using its formula. Here is an example:
g0 = median(G_0);
% Linearize the data
log_f = log(f);
% Calculate predicted values using the exponential model
predicted_f = g0 * a.^(0:length(f)-1);
% Calculate MAPE
mape = 100 * mean(abs((f - predicted_f) ./ f));
From MATLAB R2022b a direct 'mape' function was introduced:
mape_1 = mape(predicted_f,f);
The following MATLAb Answers can be referred:
The following MathWorks documentations can be referred to know more:

Kategorien

Mehr zu Communications Toolbox finden Sie in Help Center und File Exchange

Produkte


Version

R2017b

Community Treasure Hunt

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

Start Hunting!

Translated by