How to find the maximum value of two variables of a function in MATLAB

6 次查看(过去 30 天)
Hi everyone,
I would like to find the maximum value of \eta and xo in the function below using numerical simulation:
z=1e6*log2(1+(10^(30/10)*4*(3e8/(4*pi*1e12))^2*15^(-4)*exp(-0.0016*15))/10^(-90/10))*(-1/(1e4^(1-0.5)-1))+ 1e6*log2(1+(10^(30/10)*4*(3e8/(4*pi*1e12))^2*x0^(-2)*exp(-0.0016*x0))/10^(-90/10))*((100/eta)^(1-0.5)-1)/(1e4^(1-0.5)-1);
\eta range and xo range are:
eta_range = 0.01:0.01:1;
x0_range = 1:1:100;
  2 个评论
Rik
Rik 2023-6-20
I recovered the removed content from the Google cache (something which anyone can do). Editing away your question is very rude. Someone spent time reading your question, understanding your issue, figuring out the solution, and writing an answer. Now you repay that kindness by ensuring that the next person with a similar question can't benefit from this answer.
Matt J
Matt J 2023-6-20
Back-up copy of Hadeel Obaid's question:
Hi everyone,
I would like to find the maximum value of \eta and xo in the function below using numerical simulation:
z=1e6*log2(1+(10^(30/10)*4*(3e8/(4*pi*1e12))^2*15^(-4)*exp(-0.0016*15))/10^(-90/10))*(-1/(1e4^(1-0.5)-1))+ 1e6*log2(1+(10^(30/10)*4*(3e8/(4*pi*1e12))^2*x0^(-2)*exp(-0.0016*x0))/10^(-90/10))*((100/eta)^(1-0.5)-1)/(1e4^(1-0.5)-1);
\eta range and xo range are:
eta_range = 0.01:0.01:1;
x0_range = 1:1:100;

请先登录,再进行评论。

回答(2 个)

Matt J
Matt J 2023-5-10
编辑:Matt J 2023-5-10
Your function z is separable and monotonically decreasing in both variables. So, it should come as no surprise that the smallest values of eta and x0 give the maximum. However, you can verify that with the code below:
eta = (0.01:0.01:1)';
x0 = (1:100);
z=1e6.*log2(1+(10.^(30./10).*4.*(3e8./(4.*pi.*1e12)).^2.*15.^(-4).*exp(-0.0016.*15))./10.^(-90./10)).*(-1./(1e4.^(1-0.5)-1))+ 1e6.*log2(1+(10.^(30./10).*4.*(3e8./(4.*pi.*1e12)).^2.*x0.^(-2).*exp(-0.0016.*x0))./10.^(-90./10)).*((100./eta).^(1-0.5)-1)./(1e4.^(1-0.5)-1);
[maxval,k]=max(z,[],'all','linear')
maxval = 1.1152e+07
k = 1
[i,j]=ind2sub(size(z),k);
eta_max=eta(i),
eta_max = 0.0100
x0_max=x0(j),
x0_max = 1
  3 个评论
Matt J
Matt J 2023-5-11
@Hadeel Obaid Torsten and I reached the same result. And, as I outlined above, you did not need any code to reach this result. The maximizing point is obvious from the expression for z.

请先登录,再进行评论。


Torsten
Torsten 2023-5-10
eta = 0.01:0.01:1;
x0 = (1:1:100).';
z = 1e6*log2(1+(10^(30/10)*4*(3e8/(4*pi*1e12))^2*15^(-4)*exp(-0.0016*15))/10^(-90/10))*(-1/(1e4^(1-0.5)-1))+ 1e6*log2(1+(10^(30/10)*4*(3e8/(4*pi*1e12))^2*x0.^(-2).*exp(-0.0016*x0))/10^(-90/10))*((100./eta).^(1-0.5)-1)/(1e4^(1-0.5)-1);
maximum_z = max(max(z))
maximum_z = 1.1152e+07
[i,j] = find(z==maximum_z)
i = 1
j = 1

类别

Help CenterFile Exchange 中查找有关 Loops and Conditional Statements 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by