how to select a text file from a directory and read it in GUI matlab

3 ビュー (過去 30 日間)
Jwana
Jwana 2012 年 12 月 22 日
Hello all,
I have a GUI system that should select a text file from a directory,open it and read it in a code.. I have this code for that( the part of getting the text file):
function FindCallback(source,eventdata)
[FileName,PathName]= uigetfile('*.txt','browse')
s={};
fid = fopen('*.txt');
tline = fgetl(fid);
while ischar(tline)
s=[s;tline];
tline = fgetl(fid);
end
it shows me an error:
Invalid file identifier. Use fopen to generate a valid file
identifier.
Error in ==> GUI_oo>FindCallback at 77
tline = fgetl(fid);
??? Error while evaluating uicontrol Callback
any advice..
Thanks

採用された回答

Azzi Abdelmalek
Azzi Abdelmalek 2012 年 12 月 22 日
編集済み: Azzi Abdelmalek 2012 年 12 月 22 日
Instead of fid = fopen('*.txt') use ;
file=fullfile(PathName,FileName)
fid = fopen(file);

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeLarge Files and Big Data についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by