How to monitor the output of a function when being called in a separate function
조회 수: 1 (최근 30일)
이전 댓글 표시
I created a function that pulls information for a certain day from NASA's website using ftp when given a date. I am calling it in a different function and I want to know how to check if something was pulled or not. The function that pulls the information has code that will end the function if there is no information for the given date how can I have it so that the new function can tell if there was no file retrieved? And if a file is retrived then how can I check if it is already exists in the Matlab path? What I need is help with writing out how to call the function fetchRinex to a different function and see if a file is retrieved.
The following is the code that retrieves the files from NASA's website, not the new function as it isn't written yet
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
function fetchRinex(startUtc, stopUtc)
% If no start date is given then the computer's current date and time is
% taken
if nargin==0
startUtc = fix(clock);
end
% If no stop date is given then the start date will also be the stop date
if nargin<2
stopUtc = startUtc;
end
gpsStartTime = utc2gps(startUtc);
gpsStopTime = utc2gps(stopUtc);
gpsStartTimeSec = gpst2sec(gpsStartTime);
gpsStopTimeSec = gpst2sec(gpsStopTime);
% Build up a vector of time stamps to pull data
timeVectGpsSec = (gpsStartTimeSec:86400:gpsStopTimeSec)';
days2get = length(timeVectGpsSec); % days to get
% Convert that time vector back to UTC to extract the day number into the
% year.
timeVectGps = sec2gpst(timeVectGpsSec);
[utcTime, leapSecs, doy] = gps2utc(timeVectGps);
for i=1:days2get
row = i;
% Constructing the string for the website from which ephemeris is being retrieved.
ftpobj = ftp('cddis.nasa.gov');
dirStr = sprintf('/gnss/data/daily/%d/brdc/',utcTime(row,1)) ;
cd(ftpobj, dirStr);
fileStr = sprintf('BRDC00IGS_R_%d%03d0000_01D_MN.rnx.gz', utcTime(row,1), doy(i));
d=dir(ftpobj,fileStr);
if isempty(d) % If the file does not exist then a popup error message will be displayed
f = errordlg(['File: ' fileStr ' does not exist',' Please try again ']);
return % If the file does not exist then the function will stop
end
mget(ftpobj, fileStr, '.'); % If the file exists it will be retrieved
% Unzip file(s) to subdirectory titled "RINEXdata", if the subdirectory does not exist then it will be created
gunzip(fileStr, 'RINEXdata');
delete(fileStr); % delete the zipped file(s) leaving only the unzipped version
end
댓글 수: 0
채택된 답변
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Search Path에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!