Calculating number in a string

2 次查看(过去 30 天)
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 个)

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 CenterFile Exchange 中查找有关 Software Development Tools 的更多信息

产品


版本

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by