Calculating number in a string
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Ben Hischar
am 30 Aug. 2021
Bearbeitet: Ben Hischar
am 5 Sep. 2021
SampleText.txt
file = 'SampleText.txt';
any assitance would be much appriciated, thanks.
0 Kommentare
Akzeptierte Antwort
Wan Ji
am 30 Aug. 2021
Then do following code
for i = 1:1:nLines
fprintf('%d: %s\n',i,fileStr{i})
end
fprintf('This file has %d lines', nLines)
Weitere Antworten (1)
Mathieu NOE
am 30 Aug. 2021
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 Kommentar
Mathieu NOE
am 30 Aug. 2021
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
Siehe auch
Kategorien
Mehr zu Software Development Tools finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!