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

I'm writing a paper where I'm going to use markov models to evalute a device. My base for this paper is the paper written by H. Timbley. I have never used Mathematica before and thought that I would start by trying the complete code that Timbley has written in the appendix of the paper. The code is:

DiscreteMath`Combinatorica`;

IndexOf[vector , e ] := Position[vector, e][[1, 1]];

device =

{{"Clock", "Clock", "Clock", "Clock", "Clock", "Clock"},

{"Quick Defrost", "Quick Defrost", "Quick Defrost",

"Quick Defrost", "Quick Defrost", "Quick Defrost"},

{"Timer1", "Timer1", "Timer2", "Timer1", "Timer2", "Timer1"},

{"Clock", "Clock", "Clock", "Clock", "Clock", "Clock"},

{"Clock", "Quick Defrost", "Power1",

"Power2", "Power1", "Power2"}

};

buttonNames = {"Clock", "Quick Defrost", "Time", "Clear", "Power"};

stateNames = {"Clock", "Quick Defrost", "Timer1", "Timer2", "Power1",

"Power2"};

numberOfStates = Length@stateNames;

numberOfButtons = Length@buttonNames;

start = IndexOf[stateNames, "Power1"];

goal = IndexOf[stateNames, "Power2"];

Until then the code work just fine, but when I type in the next section described in the appendix (see below), some error codes pop up.

Do[randomUser[[i, IndexOf[stateNames, device[[b, i]]]]] +=

1/numberOfButtons, {b, numberOfButtons}, {i, numberOfStates}];

Error codes:

Part::partw: Part 1 of {} does not exist. >>

Part::pspec: Part specification {}[[1,1]] is neither a machine-sized integer nor a list of machine-sized integers. >>

Part::partw: Part 1 of {} does not exist. >>

Set::pspec: Part specification {}[[1,1]] is neither a machine-sized integer nor a list of machine-sized integers. >>

Part::partw: Part 3 of {Quick Defrost,(Quick Defrost)^5} does not exist. >>

General::stop: Further output of Part::partw will be suppressed during this calculation. >>

Part::pspec: Part specification {}[[1,1]] is neither a machine-sized integer nor a list of machine-sized integers. >>

Set::pspec: Part specification {}[[1,1]] is neither a machine-sized integer nor a list of machine-sized integers. >>

Part::pspec: Part specification {}[[1,1]] is neither a machine-sized integer nor a list of machine-sized integers. >>

General::stop: Further output of Part::pspec will be suppressed during this calculation. >>

Set::pspec: Part specification {}[[1,1]] is neither a machine-sized integer nor a list of machine-sized integers. >>

General::stop: Further output of Set::pspec will be suppressed during this calculation. >>

Is there anybody that could tell me what's wrong with the code?

**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!

# Problems with mathematica code

Loading...

Similar Threads - Problems mathematica code | Date |
---|---|

Mathematica Solve Perturbation problem with mathematica | Dec 7, 2017 |

Mathematica For looping problem not getting answer | May 24, 2017 |

Mathematica Graph Plotting Problem in Mathematica | Nov 22, 2016 |

Mathematica - Countour plot problem | Jun 10, 2015 |

Mathematica problem: two nigh-identical codes | Mar 27, 2012 |

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