Read dada from a file
Show older comments
So, I have an input text file(.txt) looking something like this: X:0.34, y:0.45, z:0.32, t:0.002
How can I read each variable separately like a column for x, one for y... and store them into matlab?
7 Comments
Luna
on 19 Jul 2019
Could you please share your .txt file to see how it is structured?
1) are the 2 colons that follow 't' intentional?
2) are the data listed in columns like this
X:0.34, y:0.45, z:0.32, t::0.002
X:0.34, y:0.45, z:0.32, t::0.002
X:0.34, y:0.45, z:0.32, t::0.002
X:0.34, y:0.45, z:0.32, t::0.002
X:0.34, y:0.45, z:0.32, t::0.002
X:0.34, y:0.45, z:0.32, t::0.002
I agree with Luna that attaching an example txt fill will save a lot of time and increase the precision to the answer that you need.
dan oltean
on 20 Jul 2019
dan oltean
on 20 Jul 2019
We can work with that! In the image you shared earlier, each set of x:... Y:... Z:... Ts:... has it's own row. But in the text you shared above, it looks like there can be multiple X,Y,Z,Ts per line. In fact, there are no line breaks in the text you shared so all of that is on 1 line. These details are important to set straight before designing a solution.
Tudor Oltean
on 20 Jul 2019
Each X,Y,Z,Ts has it's own row.
thank you
Accepted Answer
More Answers (0)
Categories
Find more on Shifting and Sorting Matrices in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!