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 commentaires

KSSV
KSSV le 18 Nov 2016
Can you tell me what is length(dirListing)?
Have you tried to check is baseFilename a text file?
about 60 file in the folder
KSSV
KSSV le 18 Nov 2016
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
SANKAR JYOTI NATH
SANKAR JYOTI NATH le 18 Nov 2016
and from that data i have to do some calculation
KSSV
KSSV le 18 Nov 2016
If dirListing has got the files information, then your code shall work.
SANKAR JYOTI NATH
SANKAR JYOTI NATH le 18 Nov 2016
how can i provide the file information to dirlisting?
KSSV
KSSV le 18 Nov 2016
what is length(dirlisting)? dirlisting(1).name shows text file 0000.txt ?
SANKAR JYOTI NATH
SANKAR JYOTI NATH le 18 Nov 2016
length is 60, and yes dirlisting(1).name shows text file 0000.txt
KSSV
KSSV le 18 Nov 2016
Then it should work, once you import data must have the file data in it.

Réponses (0)

Cette question est clôturée.

Clôturé :

le 20 Août 2021

Community Treasure Hunt

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

Start Hunting!

Translated by