Calculating number in a string

3 vues (au cours des 30 derniers jours)
Ben Hischar
Ben Hischar le 30 Août 2021
Modifié(e) : Ben Hischar le 5 Sep 2021
SampleText.txt
file = 'SampleText.txt';
any assitance would be much appriciated, thanks.

Réponse acceptée

Wan Ji
Wan Ji le 30 Août 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)
  1 commentaire
Ben Hischar
Ben Hischar le 30 Août 2021
Worked a treat i thought i needed a loop thanks mate

Connectez-vous pour commenter.

Plus de réponses (1)

Mathieu NOE
Mathieu NOE le 30 Août 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 commentaire
Mathieu NOE
Mathieu NOE le 30 Août 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

Connectez-vous pour commenter.

Catégories

En savoir plus sur MATLAB dans Help Center et File Exchange

Produits


Version

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by