필터 지우기
필터 지우기

spdfcdfinfo - how to avoid a crash when the cdf file is corrupted?

조회 수: 1 (최근 30일)
Harri
Harri 2023년 1월 17일
답변: Swaraj 2023년 3월 9일
I use spdfcdfinfo and spdfcdfread for loading cdf files to matlab. Occasionally the cdf files can be corrupted on a data server and then these two cdf scripts crash whentrying to load data to matlab. Is there any method to check that the cdf file is readable before trying to use spdfcdfinfo and spdfcdfread?

답변 (1개)

Swaraj
Swaraj 2023년 3월 9일
One approach is to use the built-in MATLAB function exist to check if the file exists and is readable.
Another approach is to use the “cdflib” function “cdflib.open” to open the CDF file and check if it is readable.
To avoid the program crashes, always use try-catch blocks. Put the code using which you are checking the file inside the try block and put the corresponding catch block.
Go through the below documentations:
Documentation for exist function.
Documentation for CDF Library.
Documentation for try-catch blocks.

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by