이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Event base simulation in matlab
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi, I don't know how to do event based simulation in matlab. Just need a start for it, this question is a start part of my bigger task.
i have this,
arrival_departure_frequency =
0.0000 5.9489 0
0.0000 6.6353 0
0.0001 6.9292 0
0.0001 6.9361 0
0.0001 7.2979 0
0.0001 7.7989 0
0.0002 7.9419 0
0.0002 8.8358 0
0.0002 8.8383 0
0.0002 9.0600 0
First column is my event_arrivals and the 2nd column is event_departure. I want to change the value of third column from 0 to 1 when the simulation is in between arrival time and the departure time.
Once the event_departure arrives it again back set to O. Thank you so much.
댓글 수: 27
Aftab Ahmed Khan
2014년 6월 11일
편집: Aftab Ahmed Khan
2014년 6월 11일
Hi,
Any value in the first column will trigger the change in the third column(change its value from 0 to 1 upon arrival and from 1 to 0 up on file departure).
Until now i did this, i don't know how to release the channel (i.e from 1 to 0).
for i =1:10
timenow = event_arrivals(i);
no_channels = find(BS_channeltable == 0);
first_available = min(no_channels);
%%Allocating the Channel on the file arrival
if timenow == (event_arrivals(i))&&(first_available ~=0)
BS_channeltable(first_available) = 1;
fprintf(fid,'Frequency is assigned.\n');
Releasing the channel on file departure
elseif timenow == event_departures(i)
release_channel = find(BS_channeltable==1);
last_occuped = max(release_channel);
BS_channeltable(last_occuped) = 0;
fprintf(fid,'Frequency is released.\n');
Aftab Ahmed Khan
2014년 6월 11일
I only want to change the values in the third column from 0 to 1 according to the first column values and from 1 to 0 according to the second column values.
José-Luis
2014년 6월 11일
Ok, but what are the conditions?
if first_col = what then third_column what?
if second_col = what then third_column what?
Aftab Ahmed Khan
2014년 6월 11일
sorry,if i look a bit dump here.
if now_time = 0.0000 then change the value in the third column from 0 to 1
and so on.....
if now_time = 5.9489 then change the value in the third column from 1 to 0.
Similarly for the remaining 9 events as well.
Aftab Ahmed Khan
2014년 6월 11일
for 0 to 1, the values in the first column are the trigger time while for 1 to 0 the values in the second column are the trigger times.
Aftab Ahmed Khan
2014년 6월 11일
This is my simulation time, when it equals to first event arrival time it changes value in the third column from 0 to 1 and when its value equal to the first event departure time, it changes that value back from 1 to 0.
Aftab Ahmed Khan
2014년 6월 11일
Actually, i don't know how to do time based simulation in which we look at the simulation time.
Aftab Ahmed Khan
2014년 6월 11일
Hi, can you help me like how to do a event based simulation in Matlab. Even if it is a very simple example. Like there are some arrivals events and you do something very simple when that time arrives, may be change 0 to 1 or vice versa in another matrix.
José-Luis
2014년 6월 11일
I don't understand what your _arrival_events_are or where they come from. The rest of your problem sounds like it could be solved by two nested if's.
Aftab Ahmed Khan
2014년 6월 11일
Let me explain it further, if it helps,
As you see in the question at time = 0.0000 sec (first value) the file arrives and at time t = 5.9489 sec it departs, so for this duration of time i want the value in the third column which is first at 0 will turn to 1 and when time passes 5.9489 it again turns back to 0. Similarly for the rest of the remaining 9 events to follow.
Abhishek M
2014년 6월 12일
Are the rows which you provided are of different iterations??
Are these rows related to each other or how is it?? Can you please give some details about it??
0.0000 5.9489 0
0.0000 6.6353 0
Aftab Ahmed Khan
2014년 6월 12일
Let me explain it to you,
Let say i want to run my simulation for a time of 20 seconds. So when that simulation time equals to the first value (0.0000) of the first column, it changes 0 to 1 in the third column and so on.
And when the simulation time equals to the first value in the second column (5.9489) it changes back the value in the third column from 1 to 0 back.
Abhishek M
2014년 6월 12일
I guess the 1st 2 columns are inputs and the 3rd column is output{0/1}. What are the other rows, are they different probabilities of inputs?? and are these rows related to each other??
Aftab Ahmed Khan
2014년 6월 12일
Yes they are, like at any value of the first column the value in the third column changes and again when time equals to any value in the second column the value in the third column changes back.
Abhishek M
2014년 6월 12일
편집: Abhishek M
2014년 6월 12일
will that work aftab??
for example consider these 2 rows
0.0000 6.6353 0
0.0001 6.9292 0
until 0.000 to 6.6353 value will be 1 and what will be the value between 6.6353 to 6.9292. Or else does your input resets after each row and start again with the next row??
Aftab Ahmed Khan
2014년 6월 12일
Since 6.6353 and 6.9292 having different output location, so at 6.6353 its corresponding 1 will change back to 0 and at 6.9292 its corresponding 1 will change back to 0 too.
Aftab Ahmed Khan
2014년 6월 12일
i mean, that the values in the third columns are reserved for its corresponding values in the other two columns having the same row number.
Aftab Ahmed Khan
2014년 6월 12일
Hi Abhishek, i am working on the same task right now will share may code with you shortly may be that will help you to understand what i want to achieve here.
Aftab Ahmed Khan
2014년 6월 12일
Hi Abhi, This is what i have done and it work so for (little bit). The problem i have now is in the last line of this code in the arrivals variable. I want to remove only the first value in the arrivals variable, like one by one during each while loop execution but it doesn't behave so such.
tmax = 30;
nowtime = 0;
A = 2;
D = 2;
while nowtime < tmax
nowtime = min(arrivals);
available_channels = find((BS_channeltable)==0);
first_available = min(available_channels);
BS_channeltable(first_available) = 1;
fprintf(fid,'\n One channel is allocated.');
arrivals = arrivals(A:end);
A = A+1;
end
Aftab Ahmed Khan
2014년 6월 12일
Hi, I just managed what i wanted to achieve. Thank you so much dear. i really appreciate your time and support. Take care......
Abhishek M
2014년 6월 13일
Cool.. I saw your recent query. That question seems to be more clear than this. Anyways good to know you got your solution.
Cheers.
채택된 답변
Abhishek M
2014년 6월 11일
Hi Aftab, I insist you to use stateflow for this logic. You can create your events and trigger the output based on your logic.
댓글 수: 3
Aftab Ahmed Khan
2014년 6월 11일
Hello, i have tried up to this point but how can i introduce the departure time with it.
for i =1:10
timenow = event_arrivals(i);
no_channels = find(BS_channeltable == 0);
first_available = min(no_channels);
if timenow == (event_arrivals(i))&& (first_available ~=0)
BS_channeltable(first_available)=1;
end
end
Please help me with it.
Aftab Ahmed Khan
2014년 6월 11일
편집: Aftab Ahmed Khan
2014년 6월 11일
Hi,
I have managed up to this point but how can i release the channel from it as it will never reach to the departure time of the files.
for i =1:10
timenow = event_arrivals(i);
no_channels = find(BS_channeltable == 0);
first_available = min(no_channels);
%%Allocating the Channel on the file arrival
if timenow == (event_arrivals(i))&&(first_available ~=0)
BS_channeltable(first_available) = 1;
fprintf(fid,'Frequency is assigned.\n');
Releasing the channel on file departure
elseif timenow == event_departures(i)
release_channel = find(BS_channeltable==1);
last_occuped = max(release_channel);
BS_channeltable(last_occuped) = 0;
fprintf(fid,'Frequency is released.\n');
end
end
and how can i get my simulation to the departure time?
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Beamforming에 대해 자세히 알아보기
태그
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)