필터 지우기
필터 지우기

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

조회 수: 6 (최근 30일)
Hadeel Obaid
Hadeel Obaid 2023년 5월 10일
댓글: Matt J 2023년 6월 20일
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