SampleText.txt
file = 'SampleText.txt';
any assitance would be much appriciated, thanks.

 채택된 답변

Wan Ji
Wan Ji 2021년 8월 30일

0 개 추천

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일

0 개 추천

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

댓글을 달려면 로그인하십시오.

카테고리

도움말 센터File Exchange에서 Logical에 대해 자세히 알아보기

제품

릴리스

R2021a

질문:

2021년 8월 30일

편집:

2021년 9월 5일

Community Treasure Hunt

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

Start Hunting!

Translated by