I have a collection of data output that is really composed of N = integer # of interleaved datasets. I have a separate calculation that tells me the value of N. I'm trying to decompose the data into mini-datasets and perform a simple analysis on them.
The raw dataset is:
data = [185.310036632308 185.512007636984 186.306844236548 186.528138471704 187.303737370698 187.545236753824 188.299820779158 188.562095668486 189.295658588882 189.578734814646 190.291895662591 190.594513645617 191.286641304508 191.611037957123 192.282044124896 192.627257895713 193.276914735870 193.643536979820 194.271905231774 194.659684369798 195.266728214912 195.676026040601 196.261394685284 196.691609922683].'
The format of the data will basically be overlapping lists. So, if N=2 then the mini-datasets would be of the form data1=(data[i] data[i+2] data[i+4] ...) and data2 = (data[i+1] data[i+3] data [i+5] ...).
Q1: How can I incorporate the iterator i into the variable name?
I figured out how to partition the datasets for arbitrary values of N with the following for loop. In the example below N=2 but it could be any integer. The code below works but it overwrites the variable name 'datai' each time. How can I incorporate the iterator i into the variable name so this doesn't happen and I can access the variables later?
for i= 1:N
Q2: How do I perform element-by-element operations on an array to create a new array?
I'd like to take this a step further and calculate properties on an element-by-element basis and form a new array. As a simple example, suppose I want to modify matlabs diff operation to calculate the difference across a point instead of just the difference between successive pairs of points. So instead of differences1=(data1[k]-data1[k+1] data1[k+1]-data[k+2 ...) for k=1:end of data1, I want to calculate alt_differences1=( (data1[k-1]-data1[k+1])/2 (data1[k]-data1[k+2])/2 ...) for k=2:end of data1. How can I write a simple element by element operation like this?