How do i extract this text data columns by columns ? thanks

1 回表示 (過去 30 日間)
Stephen toh
Stephen toh 2012 年 11 月 2 日
DEADBEEFDEADBEEF encrypt
deadbeefdeadbeef encrypt
DEADBEEFDEADBEEF sign
deadbeefdeadbeef sign
0123456789ABCDEF encrypt
0123456789ABCDEF sign
,1.3/a@4$pR6^-?" sign
,1.3/a@4$pR6^-?" encrypt
What code should i use to receive the data in columns?
  2 件のコメント
Azzi Abdelmalek
Azzi Abdelmalek 2012 年 11 月 2 日
what do you mean?
Stephen toh
Stephen toh 2012 年 11 月 3 日
much thanks. i want to use the data above in columns as a input argument to my function. for eg, the first column contain the 16 ascii characters while the second column just read either 'encrpt' or 'sign'

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

採用された回答

Mats
Mats 2012 年 11 月 2 日
I guess you mean something like this:
fileID = fopen('data.txt');
C = textscan(fileID, '%s %s','delimiter', ' ');
fclose(fileID);
column1 = C{1}, column2 = C{2}
  1 件のコメント
Stephen toh
Stephen toh 2012 年 11 月 3 日
Thanks for the help, just another qn. If i were to read the data in each columm separately, is there any way i can verify whether each row in the 1st column is a 16 ASCII character and the second column is either 'encrypt' or 'sign'?
i.e : After extracting the data form the file,
i want to verify rowwise 'DEADBEEFDEADBEEF' is a ASCII character then correspondingly verify ' encrypt' and not 'sign'
this process will loop until theres no more data, meaning we have no idea how much data we are given in the text file. Yup greatly appreciated if u give me some advice.

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeStatistics and Machine Learning Toolbox についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by