Can any one help me in adding new line space to the result. Thanks in advance
4 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
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 comentarios
Respuestas (2)
Walter Roberson
el 5 de Feb. de 2014
result = strcat(result,sprintf('\n'));
2 comentarios
RajyaLakshmi
el 6 de Feb. de 2014
Editada: Walter Roberson
el 6 de Feb. de 2014
Walter Roberson
el 6 de Feb. de 2014
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
el 6 de Feb. de 2014
Why do all that? Just use fgetl() or fgets().
thisLine = fgets(fid);
lineWithExtraLineFeed = sprintf('%s\n', thisLine);
2 comentarios
Ver también
Categorías
Más información sobre Other Formats en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!