×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Contact US

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

understanding loop

understanding loop

understanding loop

(OP)
Hi everyone,
I would like to simulate as a start the throw of two dices and want to check how many times I get a certain value from 0 to 12.

I used a while loop (see attachment) but it doesn't work as it never exit the loop. N is the number of throws to try. Y[0,P is a vector, j is an index. Z is the histogram that should contain the result (but actually I guess there is a problem also here as it looks I never compute any of the instruction from D <- to j+1).

Where am I wrong? Must be very easy but I didn't get probably the logic of these loop programming. Thanks for any help,
pagheca

RE: understanding loop

The loop is executing, but all it's doing is incrementing Y[0,0 from 0 to 100.  Change the second line of your loop to the following to see the total for each possibility:

Y[0,(D-2) := Y[0,(D-2) + 1

[ is vector subscript

Peter
 

RE: understanding loop

Also, you have one extra column in Y, there are only 11 possibilities not 12.

Peter
 

RE: understanding loop

(OP)
ok, thanks for all the advice! Now it works.
pagheca
 

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members! Already a Member? Login



News


Close Box

Join Eng-Tips® Today!

Join your peers on the Internet's largest technical engineering professional community.
It's easy to join and it's free.

Here's Why Members Love Eng-Tips Forums:

Register now while it's still free!

Already a member? Close this window and log in.

Join Us             Close