fclose() - How do I close all open files but one?

조회 수: 11 (최근 30일)
Jean Laverenne
Jean Laverenne 2017년 11월 21일
답변: Walter Roberson 2017년 12월 1일
I'd like to close all my open files but one, is there a simple way to do it? Simpler than deleting them one by one?
It's possible for variables with:
clearvars -except variable_needed
But unsurprisingly the following does not work:
fclose all -except fileID
Thanks,

답변 (2개)

Tony Mohan Varghese
Tony Mohan Varghese 2017년 12월 1일
Currently, there is no way to close all open files, except one.

Walter Roberson
Walter Roberson 2017년 12월 1일
There is no direct way. You can
arrayfun(@fclose, setdiff(fopen('all'), fileID));
provided the fileID is given as numeric.

카테고리

Help CenterFile Exchange에서 Low-Level File I/O에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by