unable to open a file from a folder........help

yourFolder ='C:\Users\Parag\Desktop\open\files';
dirListing = dir([yourFolder '/*.txt*']);
baseFileName = dirListing(1).name;
data=importdata(baseFileName)
set(handles.display2,'string',data);
files are:
0000.txt
0010.txt
0020.txt
0030.txt ...................................

10 Comments

Can you tell me what is length(dirListing)?
Have you tried to check is baseFilename a text file?
Then is length(dirListing) is 60? How are txt files? What data it has?
it has some numeric data like this
2.32611e+006 66 7.21110
2.32611e+006 75 7.81025
2.32611e+006 99 7.00000
2.32611e+006 108 7.28011
2.32611e+006 117 7.21110
2.32611e+006 126 7.07107
2.32611e+006 159 7.28011
2.32611e+006 168 8.06226
2.32611e+006 177 7.81025
2.32611e+006 210 7.28011
2.32611e+006 219 7.21110
2.32611e+006 228 7.07107
2.32611e+006 261 7.28011
2.32611e+006 270 8.06226
2.32611e+006 279 7.07107
2.32611e+006 312 7.07107
2.32611e+006 321 8.06226
2.32611e+006 330 7.07107
2.32611e+006 363 7.07107
and from that data i have to do some calculation
If dirListing has got the files information, then your code shall work.
how can i provide the file information to dirlisting?
what is length(dirlisting)? dirlisting(1).name shows text file 0000.txt ?
length is 60, and yes dirlisting(1).name shows text file 0000.txt
Then it should work, once you import data must have the file data in it.

Answers (0)

This question is closed.

Asked:

on 18 Nov 2016

Closed:

on 20 Aug 2021

Community Treasure Hunt

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

Start Hunting!