I have a function which has discrete time step ,discrete length from origin . These two give height of the function. For example at time 1.2sec , and length 5.5cm from origin height is 10cm. The step size of time is 0.4sec and length step size is 0.5cm. How to store this, I cannot use 2D array with time and length as indexes because those are floating point numbers , which is best method to store this kind of data?
I cannot use 2D array with time and length as indexes because those are floating point numbers
Since you're using
discrete time [and length] step[s] with fixed step sizes
0.4sec and 0.5cm, you actually can use an integer-indexed array. For f(i,j), i~time, j~length, just calculate time = time0 + i*dt, where time0=0 (or any origin you like), and dt=0.4 (as per your post). And similarly for the length dimension. And note that both functions are easily invertible in case you need to find the indices corresponding to a given time,length (you also might want to write an interpolation function between i,j points).