Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

# Determine times for three variables using Least squares powerfit

1 visualización (últimos 30 días)
Juan Barragan el 15 de Abr. de 2022
Cerrada: Matt J el 21 de Dic. de 2023
Hello, I'm having trouble figuring out the thinking time, braking car time and motorcycle braking time at speeds 20km/hr, 50km/hr, 80km/hr, 100km/hr, 120km/hr and 150km/hr using the least squares power fit method
##### 3 comentariosMostrar 1 comentario más antiguoOcultar 1 comentario más antiguo
Torsten el 15 de Abr. de 2022
In other words:
What is "least-squares powerfit" ?
Juan Barragan el 17 de Abr. de 2022
yes, I've been having difficulty on figuring out the equations for each time

### Respuestas (1)

Ravi el 21 de Dic. de 2023
Hi Juan Barragan,
I understand you are facing trouble in arriving at equations for the variables. I hope the following approach will be helpful to you.
The least squares power fit method is a technique used to find the best-fitting power function that minimizes the sum of the squared differences between the observed and predicted values.
A power-law relationship is represented by the equation,
y = a * x ^ b
Where a is a coefficient and b is the exponent.
The following function can help you in obtaining the equation.
speed = [30, 45, 60, 75, 90, 120];
thinking = [6, 9, 11, 15, 17, 22];
powerfit(speed, thinking);
Equation: y = 0.2436x^0.9432
y = 0.2436 * (20 ^ 0.9432)
y = 4.1097
function [] = powerfit(x, y)
% Perform least squares power fit
logx = log(x);
logy = log(y);
% Use polyfit for linear regression on transformed data
p = polyfit(logx, logy, 1);
% Extract coefficients
a = exp(p(2)); % Intercept term corresponds to log(a)
b = p(1); % Slope corresponds to exponent b
% Display results
fprintf('Equation: y = %.4fx^%.4f\n', a, b);
end
The above function “equation” takes input two arguments “x” and “y” where “x” represents the Speed and “y” can take Thinking, Braking Car and Braking motorcycle.
Once after obtaining the equation, we can find the response variable by simply substituting the Speed value in place of “x” in the obtained equation.
To know more about the “polyfit” function, please refer to the following link.
Hope this explanation resolves the issue you are facing.
Thanks,
Ravi Chandra
##### 0 comentariosMostrar -2 comentarios más antiguosOcultar -2 comentarios más antiguos

La pregunta está cerrada.

### Community Treasure Hunt

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

Start Hunting!

Translated by