フィルターのクリア

read string from .txt file

1 回表示 (過去 30 日間)
raktim banerjee
raktim banerjee 2011 年 1 月 25 日
コメント済み: Michael Anderson 2022 年 12 月 6 日
Hello Sir!
There is a text file 'info.txt' containing the following line:
'banerjee.raktim 123456789045'
i want to read the strings like:
user_id = 'banerjee.raktim' % char type array. Not cell type.
password = '123456789045' % char type array. Not cell type.
i wrote this:
[username, pass] = textread('info.txt','%15c%11c',1)
But this for 15 char long & 11 char long 2 strings. What to do to read two strings of any length separated by a single space from the first line of a .txt file?
>> [username, pass] = textread('info.txt', '%s%s',1);
>> username
username =
'banerjee.raktim'
>> whos username
Name Size Bytes Class
username 1x1 90 cell array
Grand total is 16 elements using 90 bytes
I also tried this. But this is cell type array. How to convert it to char type array?

採用された回答

Walter Roberson
Walter Roberson 2011 年 1 月 25 日
Answered in the duplicate post, #403
  1 件のコメント
Michael Anderson
Michael Anderson 2022 年 12 月 6 日
that duplicate post no longer exists

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCharacters and Strings についてさらに検索

製品

Community Treasure Hunt

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

Start Hunting!

Translated by