Hello
I need my program to gather the data from the text file (created by diary) and post it on the gui i have specified for it.
I can gather the data with
fid=fopen('dontreadme.txt','r');
dataread=textscan(fid,'%s');
and returning it to the gui is also easy but i couldnt get there since i check the data acquired by this method with a display and it gives a cell array or some numbers when i mess around with it.
I want to have my text file got written on the GUI as I see it in the command window (or in the text file; since there are no inputs into the command line by the user).
Thank you in advance.

1 件のコメント

Paragon
Paragon 2015 年 9 月 26 日
I have just tried fscanf which did actually get the text but omitted the spaces or enters in between the words.

サインインしてコメントする。

 採用された回答

Star Strider
Star Strider 2015 年 9 月 26 日

0 投票

Please attach 'dontreadme.txt' (use the ‘paperclip’ icon and complete both steps) and tell us what you want to read from it.

4 件のコメント

Paragon
Paragon 2015 年 9 月 26 日
There is NOTHING unusual about the text. There are plenty of strings made up of letters/characters; all the outputs (at least the part I am interested in) are made by disp or sprintf or fprintf or something similar.
Star Strider
Star Strider 2015 年 9 月 26 日
That file doesn't look like something diary would create. What file do you actually want to read, and what do you want to get from it?
Paragon
Paragon 2015 年 9 月 26 日
From a text file, notepad, I assign the diary to create something.txt and it creates the text file which contains the command window outputs. There is nothing unusual, I am telling you. Just think about a single sentence on a text file, how would I get it out of there as a proper sentence, just like it shows up in the text file?
Star Strider
Star Strider 2015 年 9 月 26 日
Try this:
fidi = fopen('Paragon justtext.txt', 'rt');
out = textscan(fidi, '%s', 'Delimiter',{' ', '\n'});
ViewOutput = out{1}(1:20) % See The First 20 Words (Optional)
The single '' is the carriage return-linefeed that breaks the lines. I requested that by including in the 'Delimiter' name argument the cell array {' ', '\n'} value, treating spaces and carriage return-linefeed characters as delimiters (breaks between whatever data are in the file). So you have all the data in the file as discrete words, and also the places where the new lines should begin.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

質問済み:

2015 年 9 月 26 日

コメント済み:

2015 年 9 月 26 日

Community Treasure Hunt

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

Start Hunting!

Translated by