Hi(adsbygoogle = window.adsbygoogle || []).push({});

I'm working on my first matlab script that I've worked on from scratch. I've never taken a course in matlab, the only experience I've had is to modify a couple of other scripts. I'm hoping to develop my matkab skills with a 'relatively' simple monte carlo model: a 2D Ising model.

One part of my method is to take a binary array of zeros and ones, pick a 'random' element and switch the value from zero to one or vice versa. I've done this with a simple if/else command.

if I==1

I=0;

else I=1;

end

What I'd like to do is introduce a probability, so that the value flip will occur with a certain probability p. Is there anyway to add this into my if command or do I need tp try something more sophisticated?

**Physics Forums - The Fusion of Science and Community**

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Probability and If commands.

Can you offer guidance or do you also need help?

Draft saved
Draft deleted

Loading...

Similar Threads - Probability commands | Date |
---|---|

Matlab Making a short test for self-adjointness | Feb 23, 2018 |

Quick (probably easy) Latex Question | Nov 2, 2012 |

Simulink USS block - probability analysis | Jul 12, 2012 |

Simple probability distribution function on gnuplot | May 8, 2012 |

Trouble downloading mathematica packages - probably a very quick solution | Mar 23, 2012 |

**Physics Forums - The Fusion of Science and Community**