Filter löschen
Filter löschen

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

6 Ansichten (letzte 30 Tage)
Hadeel Obaid
Hadeel Obaid am 10 Mai 2023
Kommentiert: Matt J am 20 Jun. 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 Kommentare
Rik
Rik am 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 am 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;

Melden Sie sich an, um zu kommentieren.

Antworten (2)

Matt J
Matt J am 10 Mai 2023
Bearbeitet: Matt J am 10 Mai 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 Kommentare
Matt J
Matt J am 11 Mai 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.

Melden Sie sich an, um zu kommentieren.


Torsten
Torsten am 10 Mai 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

Kategorien

Mehr zu Loops and Conditional Statements finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by