How can I import multiple text files by clicking a button in MATLAB GUI ?

1 次查看(过去 30 天)
Hello, everyone!
I have to import all the text files in a folder by clicking a button in MATLAB GUI. The file contains mixed data: Text in the starting lines, followed by columns headers and data in which first 2 columns are date and time and the remaining data contains float values). I am unable to do it. Please help me out.
Thank you.
  2 个评论
KSSV
KSSV 2017-3-24
There are functions like importdata, testread, textscan to read text files. Have you read those?
Mora Akhil
Mora Akhil 2017-3-24
Hello KSSV! I have gone through those functions. I can read a single text file of such kind using only programming. My problem is, I am unable to import text files in a folder in GUI.

请先登录,再进行评论。

回答(1 个)

Nagini Venkata Krishna Kumari Palem
In my understanding you are looking for solution to read text files of different formats. You can use 'uiimport' command from command window or use 'import data' option from home tab.
  • Customize the format of imported data and variable names as required using the relevant options in import tool.
  • Click on the drop-down menu under 'Import Selection' and select 'Generate Script'.
  • Using the generated script, you can import data from other files in the same format, all you have to do is change the filename.
For more information you can refer to the following documentation pages,
If you are looking for how to import all the files from a folder, one possible solution would be to iterate through all the files in a loop.

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by