Using Newton Raphson for Root Finding and Parameters' Estimation
Show older comments
Goood Day,
I have a cubic root equation. I use newton-raphson for finding the roots. I want to do parameter estimation (tuning of the equation parameters to be able to give better prediction) using experiment data. Can anyone help me on how to do this?
Thanks for your anticipated help Regards, Isa
Answers (1)
Hi Isa,
Below is a complete MATLAB script that performs parameter estimation for a cubic root equation using experimental data. It uses the fminsearch function to minimize the sum of squared errors between the experimental data and the model predictions.
% Define the objective function
function error = objectiveFunction(params, X, Y)
a = params(1);
b = params(2);
c = params(3);
% Predicted values
Y_pred = a * nthroot(X - b, 3) + c;
% Sum of squared errors
error = sum((Y - Y_pred).^2);
end
% Main script
% Experimental data (replace with your actual data)
X = [1, 2, 3, 4, 5]; % Example input values
Y = [2.5, 3.1, 3.8, 4.6, 5.5]; % Example observed outputs
% Initial guess for parameters [a, b, c]
initialParams = [1, 0, 0];
% Perform optimization using fminsearch
options = optimset('Display', 'iter'); % Show iteration details
optimizedParams = fminsearch(@(params) objectiveFunction(params, X, Y), initialParams, options);
% Display results
disp('Optimized Parameters:');
disp(optimizedParams);
% Calculate predicted values with optimized parameters
Y_pred_optimized = optimizedParams(1) * nthroot(X - optimizedParams(2), 3) + optimizedParams(3);
% Plot the results
figure;
plot(X, Y, 'o', 'DisplayName', 'Experimental Data');
hold on;
plot(X, Y_pred_optimized, '-', 'DisplayName', 'Fitted Curve');
legend show;
xlabel('X');
ylabel('Y');
title('Parameter Estimation');
Hope this helps.
Categories
Find more on Newton-Raphson Method 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!