How to import part of the data from multiple .txt files into the MATLAB workspace as a variable
Show older comments
I have two .txt files in my directory that I want to load part of the data into a workspace variable. Both files have the same format (data starts on line 54 and ends on line 254) but different names. One is named '685_FM01_HF_7-21-2020.txt' and the other is '685_InM01_HF_7-21-2020-000019-t01-RAW.txt'. Unfortunately, I am not allowed to upload the actual .txt files by my company, but the data is formatted as follows:
-1224.895 , 34456674
4948540, 342342342
34234234, 3423423
8543574, 224234235
8049865, 4830958
Two columns, with a comma as the delimiter. Is there a way to import the data from the two textfiles into two different workspace variables? I tried using the 'import data' feature in MATLAB's interface, but it only does one specific file.. I think I'll need a for loop, but I don't know how to format them. I started my MATLAB journey yesterday, so apologies if this a trivial answer. Thank you for any assistance you can give.
1 Comment
Stephen23
on 12 Aug 2020
Accepted Answer
More Answers (0)
Categories
Find more on Text Files 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!