I have a code that loops through and does some computation on 5 random values from my lists of data (2187 rows long).(adsbygoogle = window.adsbygoogle || []).push({});

for i = 1:3

randomdata = round(rand(5,1).*2187);

xval = x(randomdata)

yval = y(randomdata)

numerator = length(xval).*nansum(xval.*yval) - (nansum(xval).*nansum(yval))

end

my output on the screen is as follows: 5 random values stored in xval & yval

xval =

3.3

3.2

6.4

4.3

1.2

yval =

13

33

83

42

9

numerator =

-.34

numerator =

-.12

numerator =

-.45

My question is why isnt numerator being stored as a 5x1 array like xval and yval??

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

# Storing calculations into a list

Tags:

Loading...

Similar Threads - Storing calculations list | Date |
---|---|

Matlab- storing iterations into a single matrix and file | Jan 5, 2015 |

LaTex: Where to store package, sty, etc files? | May 10, 2013 |

Cell arrray that stores with iteration a new set of values | Jan 10, 2013 |

Storing Iteration Results in Matlab | Sep 2, 2012 |

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