I need to make a program that generates random numbers between 0 and 9999 for 5 seconds, and stops if the number 2015 is generated. I must use the etime and fix functions.
Show older comments
this is what I've done so far but it doesn't seem to be working... Could anyone help me on this?
t1=clock;
while 1
t2=clock;
if etime(t2,t1)>=5.0;
Disp('not found');
break;
end
x=9999*rand(1);
Y=fix(x);
Disp(Y);
if Y == 2015
Disp('found');
break;
end
end
Accepted Answer
More Answers (1)
Walter Roberson
on 18 Nov 2015
1 vote
You know that iso-9001 does not care about which functions you call, only that you document your process completely. And the British "Redbook" and "Bluebook" security standards said nothing at all about MATLAB (and are completely replaced anyhow.) If your jurisdiction outlawed some MATLAB calls then you are going to need to point us to the source text of the law so we do not inadvertently break the rules.
Or wait a second... Is this perhaps homework that has not been marked as such??
2 Comments
Liesl
on 18 Nov 2015
Walter Roberson
on 18 Nov 2015
What I am talking about is that we expect students to specifically indicate that they are working on homework / assignments. Assignments sometimes impose restrictions that are completely unrealistic in real life.
When you ask Questions and there are restrictions on the acceptable solutions, you should indicate the restrictions and the reason for them, whether the reason is "assignment", "company policy", "legal requirements", "must meet a particular standard", "economic", "low power solution needed" and so on. Otherwise people end up wasting their time preparing explanations or solutions that are not relevant to the situation.
Categories
Find more on Aerospace Blockset in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!