Info
此问题已关闭。 请重新打开它进行编辑或回答。
why matlab shows code while use fprintf
1 次查看(过去 30 天)
显示 更早的评论
As you found it, this is a simple code to check if the file exsits. But as soon as I execute it, it not only outputs the existed file names but also shows a part of my code, as below.
clear all;
clc;
close all;
for i=1:10
for j=1:8
str1 = num2str(100+i);
str2 = num2str(i+j-1);
str = strcat(str1, '_', str2, '.', 'tif');
if(exist(str,'file')~=0)
fprintf('%s',str);
end
end
end
Result like this:
103_3.tif str1 = num2str(100+i);
str2 = num2str(i+j-1);
str = strcat(str1, '_', str2, '.', 'tif');
if(exist(str,'file')~=0)
fprintf('%s',str);
103_4.tif str1 = num2str(100+i);
str2 = num2str(i+j-1);
str = strcat(str1, '_', str2, '.', 'tif');
if(exist(str,'file')~=0)
str1 = num2str(100+i);
str2 = num2str(i+j-1);
str = strcat(str1, '_', str2, '.', 'tif');
if(exist(str,'file')~=0)
2 个评论
David Sanchez
2013-5-30
I tested your code as is and I just had the file name. Obviously there is something wrong with your machine.
Walter Roberson
2013-5-30
Could you also, for debugging purposes, show length(str) after str is constructed ?
回答(0 个)
此问题已关闭。
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!