Borrar filtros
Borrar filtros

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

6 visualizaciones (últimos 30 días)
Hadeel Obaid
Hadeel Obaid el 10 de Mayo de 2023
Comentada: Matt J el 20 de Jun. de 2023
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 comentarios
Rik
Rik el 20 de Jun. de 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 el 20 de Jun. de 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;

Iniciar sesión para comentar.

Respuestas (2)

Matt J
Matt J el 10 de Mayo de 2023
Editada: Matt J el 10 de Mayo de 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 comentarios
Matt J
Matt J el 11 de Mayo de 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.

Iniciar sesión para comentar.


Torsten
Torsten el 10 de Mayo de 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

Categorías

Más información sobre Loops and Conditional Statements en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by