Calculating number in a string

4 ビュー (過去 30 日間)
Ben Hischar
Ben Hischar 2021 年 8 月 30 日
編集済み: Ben Hischar 2021 年 9 月 5 日
SampleText.txt
file = 'SampleText.txt';
any assitance would be much appriciated, thanks.

採用された回答

Wan Ji
Wan Ji 2021 年 8 月 30 日
Then do following code
for i = 1:1:nLines
fprintf('%d: %s\n',i,fileStr{i})
end
fprintf('This file has %d lines', nLines)
  1 件のコメント
Ben Hischar
Ben Hischar 2021 年 8 月 30 日
Worked a treat i thought i needed a loop thanks mate

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

その他の回答 (1 件)

Mathieu NOE
Mathieu NOE 2021 年 8 月 30 日
hello
you can add these lines to your code :
for ci = 1:nLines
if size(fileStr{ci})>0
disp([num2str(ci) ' : ' fileStr{ci}]);
end
end
  1 件のコメント
Mathieu NOE
Mathieu NOE 2021 年 8 月 30 日
FYI, the if statement line is to not display empty cells , but if you wish to have it, just remove that statement;
all the best

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

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

製品


リリース

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by