Can any one help me in adding new line space to the result. Thanks in advance
4 ビュー (過去 30 日間)
古いコメントを表示
fid=fopen('largeadd.m','r');
result=' ';
while(feof(fid)~=1)
temp=char(fread(fid));
for i=1:max(size(temp))
if(~isspace(temp(i,1)))
result=strcat(result,char(temp(i,1)));
disp(isspace(temp(i,1)));
else
result=strcat(result,'\n');
end
end
end
end
disp(result);
0 件のコメント
回答 (2 件)
Walter Roberson
2014 年 2 月 5 日
result = strcat(result,sprintf('\n'));
2 件のコメント
Walter Roberson
2014 年 2 月 6 日
fread(fid) reads the entire file.
max(size(temp)) can be replaced by length(temp)
I have to wonder why you are doing all of this. Why not just read the file and then use
temp(isspace(temp)) = sprintf('\n');
Image Analyst
2014 年 2 月 6 日
Why do all that? Just use fgetl() or fgets().
thisLine = fgets(fid);
lineWithExtraLineFeed = sprintf('%s\n', thisLine);
2 件のコメント
参考
カテゴリ
Help Center および File Exchange で Other Formats についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!