need Matlab program to count the number of lines until dollar sign is given

1 回表示 (過去 30 日間)
leo john
leo john 2020 年 3 月 31 日
コメント済み: leo john 2020 年 4 月 18 日
This output is not used as text file.It is entered in the command window of the matlab those functions(count,findstr()) works using only in the file.
Sample output:
Enter a text:
I am a man
I love my mother
I love movie$
No.of lines=3
Kindly help me using character array or cell array no more predefined functions should be used
  1 件のコメント
leo john
leo john 2020 年 4 月 18 日
Dear Robinson sir,
Very many thanks for solving my issues.I would like to acknowledge you specially in my book publication work. I am writing a "Matlab programming for beginners" book kindly sent your designation and institution or place of work and city details if interested.
Thanks and Regards
Dr.F.Leo John

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

回答 (2 件)

KSSV
KSSV 2020 年 3 月 31 日
Read about strfind. YOu can search for you string using this.

Walter Roberson
Walter Roberson 2020 年 3 月 31 日
Read about count() and extractBefore() and newline() .
Just remember that if you find one newline then that means you have two lines.
  2 件のコメント
leo john
leo john 2020 年 4 月 1 日
The output is not used as text file.It is entered in the command window of the matlab those functions works using only in the file.
Walter Roberson
Walter Roberson 2020 年 4 月 1 日
count and extractBefore and strfind all work on string() objects or character vectors that are already in memory. They do not do file I/O themselves; for reading the file, see either fileread() or fopen() together with fgets() or fgetl()
Kindly help me using character array or cell array no more predefined functions should be used

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

カテゴリ

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