Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

why matlab shows code while use fprintf

조회 수: 1 (최근 30일)
ZhG
ZhG 2013년 5월 30일
마감: MATLAB Answer Bot 2021년 8월 20일
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
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
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!

Translated by