I have {x, y, f(x,y)} data in multiple (n x 3) arrays with unequal length, which I read in from different files in order to later plot them using ListPlot3D
. I wanted to automate the process and save the data into an indexed array. As the length is unequal, a standard 3D would not easily work (I would need to cut the zeros all the time for the plots).
I considered using variable names created by Symbol["x" <> ToString@i]
, but dealing with this is quite circumstantial.
I saw that people use indexed variables, so that is what I ended up with:
Do[x[k]=ReadList["data_"<>k<>".txt", {Number, Number, Number}], {k, 1, ndata}]
However, I learned that only symbols allow part assignments, so I e.g., cannot flip the sign using x[1][[All, 3]] *= -1
. I could copy x[1]
to an symbol, do the change there, and copy back, but that becomes circumstantial, again.
Is there a way around this?
Any thoughts how to better handle a list of unequal arrays is also appreciated.
Thank you!
Table
or several other strategies. Thenx[[1,All,3]]*=-1
should work. $\endgroup$Table
won't automatically pad with zeros. $\endgroup$