Gives the specific parameter value as set of value instead one value.

조회 수: 4 (최근 30일)
Devyani Sankhe
Devyani Sankhe 2021년 12월 11일
답변: Chunru 2021년 12월 11일
Hello guys,
I am using two variable named as "P" and "R" in the my routine with fix value. Now, i would like to use multiple set of value instead of one value and caculate the final optimal solution based on that range.
Practical explanation:
What i am using
P= 12
R=18
and using these value in my routine (Routine made of different formulas)
So, now i would like to give value are as
P= 2 to 30
R= 6 to 25
So finally, i would like to do it this two things
1)Calculate the answer from routine at each P (2 to 30) and respective R (6 to 25) value , how can i do it ?
2)Practically, I knows the what answer range from routine is suitable for me. Answer should be in the range of 10 to 12. If P and R parameters from the above set gives the asnwer in the range of 10 to 12, then routine should show me those respective P and R values at the end. So, i can use it those best P and R values in the real life.
Explanation: the Answer range is suitable for me (10 to 12)
If any of P and R values able to satisfy this condition (If answer from the routine gives the value in between 10 to 12) then those values of P and R should show at the end .
Do you think, it is possible ? Any solutions from your side, will be gratly appreciable.
Thanks a lot
Devyani
  댓글 수: 2
Devyani Sankhe
Devyani Sankhe 2021년 12월 11일
편집: Devyani Sankhe 2021년 12월 11일
Do you think, it is possible ? as you are expert from the matlab. I am not using Matlab too much. Any solutions from your side, will be highly appreciable.
Thanks a lot
Devyani
Devyani Sankhe
Devyani Sankhe 2021년 12월 11일
Do you think, it is possible ? as you are expert from the matlab. I am not using Matlab too much. Any solutions from your side, will be highly appreciable.
Thanks a lot
Devyani

댓글을 달려면 로그인하십시오.

답변 (1개)

Chunru
Chunru 2021년 12월 11일
[Pgrid, Rgrid] = meshgrid(2:30, 6:25); % all combinations of P and R values
z = zeros(size(Pgrid));
for i=1:size(Pgrid, 1)
for j=1:size(Pgrid, 2)
P = Pgrid(i, j);
R = Rgrid(i, j);
% Your function
z(i, j) = your_function(P, R);
end
end
[zmin, idx] = min(z, 'all');
pmin = P(idx);
rmin = R(idx);

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by