필터 지우기
필터 지우기

How to check for file existence in previous folder

조회 수: 73 (최근 30일)
Allan Paolo
Allan Paolo 2021년 10월 4일
답변: Image Analyst 2021년 10월 4일
Hi.
I am fully aware of "exist" to check if a file exists in the same directory: ie. exist('kvals.mat', 'file') == 2 checks if kvals.mat exists in the same directory.
How do I do this if I want to check the existence of kvals.mat in the previous directory?

채택된 답변

KSSV
KSSV 2021년 10월 4일
exist('../filename')

추가 답변 (1개)

Image Analyst
Image Analyst 2021년 10월 4일
Construct the filename in the other/previous folder, and the use isfile() to see if it exists
otherFullFileName = fullfile(otherFolder, 'kvals.mat')
if isfile(otherFullFileName)
% File exists.
else
% File does not exist.
end

카테고리

Help CenterFile Exchange에서 File Operations에 대해 자세히 알아보기

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by