Clear Filters
Clear Filters

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

6 views (last 30 days)
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 Comments
Rik
Rik on 20 Jun 2023
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 on 20 Jun 2023
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;

Sign in to comment.

Answers (2)

Matt J
Matt J on 10 May 2023
Edited: Matt J on 10 May 2023
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 Comments
Matt J
Matt J on 11 May 2023
@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.

Sign in to comment.


Torsten
Torsten on 10 May 2023
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

Categories

Find more on Loops and Conditional Statements 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!