Filter löschen
Filter löschen

How to monitor the output of a function when being called in a separate function

4 Ansichten (letzte 30 Tage)
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);
% If no stop date is given then the start date will also be the stop date
if nargin<2
stopUtc = startUtc;
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('');
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));
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
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

Akzeptierte Antwort

Matt J
Matt J am 28 Jul. 2020
Bearbeitet: Matt J am 28 Jul. 2020
You could return fileStr from the file as an output argument and perform whatever tests are needed in the calling workspace, e.g.,
fileStr = fetchRinex(startUtc, stopUtc)

Weitere Antworten (0)

Community Treasure Hunt

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

Start Hunting!

Translated by