Borrar filtros
Borrar filtros

How to check for file existence in previous folder

73 visualizaciones (últimos 30 días)
Allan Paolo
Allan Paolo el 4 de Oct. de 2021
Respondida: Image Analyst el 4 de Oct. de 2021
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?

Respuesta aceptada

KSSV
KSSV el 4 de Oct. de 2021
exist('../filename')

Más respuestas (1)

Image Analyst
Image Analyst el 4 de Oct. de 2021
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

Categorías

Más información sobre File Operations en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by