Minimum of bivariable function
2 ビュー (過去 30 日間)
古いコメントを表示
Hi everyone,
I just started using MATLAB and I'm trying to find the minmum of a bivariable function (CT(T1, T2)) and the correspoding 2D plot. Below the code used:
clear all ; clc ;
syms x;
syms T1;
syms T2;
H1=50;
%T2=10;
%T1=11;
Mp1=400;
Mc1=1500;
Mp2= 442.0684;
Mc2=1700;
H=100;
H2=H-H1;
w=0.1;
F1=@(T1)1-exp(-((T1-x)./100)).^2;
F2=@(T2) 1-exp(-((T2-x)./100)).^1.8;
f1=@(T1) 1-exp(-((H1-floor(H1./T1).*T1)-x)./100).^2;
f2=@(T2) 1-exp(-((H2-floor(H2./T2).*T2)-x)./100).^1.8;
A=@(T1)((H1./T1).*((-log(1-int(((30).*exp(-30).*x)*((1-exp(-((T1-x)./100)).^2)),0,T1)).*Mc1+(Mp1))))./H1;
B=@(T1)(-log(1-int((F1*((30).*exp(-30).*x)),0,(H1-(floor(H1./T1)).*T1)).*Mc1)./H1);
C=Mp2./H1;
D=@(T2)((H2./T2).*((-log(1-int(((1-exp(-((T2-x)./100)).^1.8))*((25).*exp(-25).*x),0,T2))).*(Mp1.*exp(w))))./H2;
E=@(T2)((-log(1-int((1-exp(-((H2-((H2./T2)).*T2)-x)./100))*((25).*exp(-25).*x),0,(H2-((H2./T2))).*T2))))*(Mc1.*exp(w))./H2;
CT=@(T1,T2)(A(T1)+B(T1)+C+D(T2)+E(T2))
Thanks.
0 件のコメント
回答 (1 件)
Shishir Reddy
2025 年 1 月 8 日
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.
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Surrogate Optimization についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!