Hi Jean
Below are the key changes and code snippets that can be added to your existing MATLAB code to find the minimum and plot the 2D function.
1. Optimization using fmincon: An optimization problem needs to be set up, to find the minimum of CT(T1, T2). This can be done as follows -
% Initial guess
T0 = [10, 10];
lb = [1, 1];
ub = [100, 100];
options = optimoptions('fmincon', 'Display', 'iter');
[T_opt, CT_min] = fmincon(@(T) CT(T(1), T(2)), T0, [], [], [], [], lb, ub, [], options);
disp(['Optimal T1: ', num2str(T_opt(1))]);
disp(['Optimal T2: ', num2str(T_opt(2))]);
disp(['Minimum CT: ', num2str(CT_min)]);
2. 2D Plotting using meshgrid and surf: To visualize the function CT(T1, T2), a grid of T1 and T2 values has to be vreated and CT can be evaluated over this grid.
[T1_grid, T2_grid] = meshgrid(1:0.5:100, 1:0.5:100);
CT_grid = arrayfun(CT, T1_grid, T2_grid);
figure;
surf(T1_grid, T2_grid, CT_grid);
xlabel('T1');
ylabel('T2');
zlabel('CT');
title('2D Plot of CT(T1, T2)');
These snippets can be integrated with the existing code to perform the optimization and visualization tasks.
For more information regarding the optimoptions and surf functions, kindly refer the following documentations -
I hope this helps.
