I am constraining constants for the dynamics of an autonomous system that I am simulating. Within a for loop of 100 iterations, I would like to give "a" a random value greater than zero, "b" a random value greater than 1/a, and "c" a random value greater than 0.5. I have an idea for the code of "a" but I am confused on how to constrain "b" and "c" so that they are random values specifically greater than 1/a and 0.5. Here is what I have for my code right now:
AS= rand(1, 200)*1000;
for ii = 1:100
a = AS(ii);
b=1/a;
c=???
end
Any suggestions on this issue are greatly appreciated. Thank you.

댓글 수: 5

Steven Lord
Steven Lord 2021년 9월 27일
You've told us the lower limits for the values the variables can take on, but what are the upper limits? Is it 1, Inf, a function of one of the other variables like b's lower limit is a function of a, etc.?
Also what distribution do you want to draw the values from?
Matthew Tortorella
Matthew Tortorella 2021년 9월 27일
There is no real upper limit, but I just found it apprpriate for context of simulation to not go above 200. I can adjust that as need be. I would prefer to get random values from a normal distribution.
Image Analyst
Image Analyst 2021년 9월 28일
@Matthew Tortorella, are you ever going to try my suggestion below?
Matthew Tortorella
Matthew Tortorella 2021년 9월 28일
@Image Analyst I tried it and it seems right for "c" but I need "b" to be greater than 1/a not greater than 0.5. Also can you explain what the c = a + (b-a) * rand equation is doing to create a random value for "c".
Matthew Tortorella
Matthew Tortorella 2021년 9월 28일
@Image Analyst I also just took another look at my Lyapunon derivative equation which is where I drew my conclusions about the retsrictions on a,b,c and they have changed. They are now: a>0, b>1/a, and c>1/2b. So the same except for "c" now.

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

답변 (1개)

Image Analyst
Image Analyst 2021년 9월 27일
편집: Image Analyst 2021년 9월 27일

0 개 추천

b = 1/a;
b = max([b, 0.5]); % Make sure b is > 0.5
c = a + (b-a) * rand;
c = max([c, 0.5]); % Make sure c is > 0.5

카테고리

도움말 센터File Exchange에서 Creating and Concatenating Matrices에 대해 자세히 알아보기

제품

질문:

2021년 9월 27일

댓글:

2021년 9월 28일

Community Treasure Hunt

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

Start Hunting!

Translated by