Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to determine specific image is empty in a specific folder
Date: Thu, 18 Feb 2010 16:22:05 +0000 (UTC)
Organization: STFC Rutherford Appleton Laboratory
Lines: 51
Message-ID: <hljpfd$a28$1@fred.mathworks.com>
References: <hljmnq$933$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1266510125 10312 172.30.248.35 (18 Feb 2010 16:22:05 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Thu, 18 Feb 2010 16:22:05 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 968489
Xref: news.mathworks.com comp.soft-sys.matlab:609338

"Zulkifli " <zulkifliaziz@yahoo.com> wrote in message <hljmnq$933$1@fred.mathworks.com>...
> Hi all,
> 
> I try to use isempty, but i won't work. What i'm trying to do firstly to call the folder directory where images is stored using the following command
> 
> bandpath = 'C:\System\band files';
> 
> then i specify the image i want using the following command
> 
> bandFiles = dir(fullfile(bandpath, 'band2.JPG'));
> 
> Then i'm stuck. 
> 
> what i'm trying to do next is to use if-else statement.
> 
> where, if the 'band2.JPG' exist, the it will imshow('band2.JPG')
> 
> else 
> 
> warndlg('No file recorded!!!','!! Warning !!');
> break;
> 
> end
> 
> the problem is that, i do not know how to write a code to justify that the band2.JPG 
> exist. pls help. thanks

Something like
% Define the Path to the File
BandPath = 'C:\System\band files';

% Create the full Filename, including Directory
Filename = fullfile(bandpath, 'band2.JPG');

% Check if the file exists
if(EXIST(Filename,'file')
    % Yes it exists
    MyImage = imread(Filename);
   
    % Do things .....
else
    % No it doesn't exist
    warndlg('No file recorded!!!','!! Warning !!');
end

Warning I haven't tried this, but I believe something along these lines should give you what I understand you want

Regards

Dave Robinson