필터 지우기
필터 지우기

How to check each number in a user given vector

조회 수: 1 (최근 30일)
Nathan Jalal
Nathan Jalal 2020년 6월 25일
편집: dpb 2020년 6월 26일
The following is the function I am trying to build. If a user doesnt give any information it work, however I am trying to have it so that when the user enters an arbitrary 1x4 vector of ones and zeros, the corresponding information is pulled. Not everything is shown in this code only the parts I think are pertinent to this question.
function fetchRINEX(days2get, startUTC, GNSSflag)
% Simple script to retrive GPS, GALILEO, BEIDOU, and GLONASS RINEX based navigation data files.
% GNSSflag = [GPSflag Galileoflag beidouflag glonassflag]
% flag = 1 Retrieve that data
if nargin==0
days2get = 1;
end
if nargin<2
startUTC = fix(clock);
end
if nargin<3
GNSSflag = [0 0 0 0];
GNSS = {'GPS','GALILEO','GLONASS','BEIDOU'};
[indx,tf] = listdlg('ListString',GNSS);
end
%%%%%%%%% This is where I need help to check which column in the vector is a 1 and which is a zero
% and then execute the following code with respect to the 1's %%%%%%%%%%%%%%%%%%%%%%%
for i=1:days2get
if sum(indx==1)>0 % If GPS is selected from the selection box, the following code will be executed.
% Build the directory string for GPS
dirStr = sprintf('/gnss/data/daily/2020/%03d/20n/', doy(i));
fileStr = sprintf('brdc%03d0.20n.Z', doy(i)); % Note this does not work for data set prior to 2000
cd(ftpobj, dirStr);
mget(ftpobj, fileStr, '.');
end
if sum(indx==2)>0 % If GALILEO is selected from the selection box, the following code will be executed.
% Build the directory string for GALILEO
dirStr = sprintf('/gnss/data/daily/2020/%03d/20l/', doy(i));
fileStr = sprintf('glps%03d0.20l.Z', doy(i)); % Note this does not work for data set prior to 2000
cd(ftpobj, dirStr);
mget(ftpobj, fileStr, '.');
end
if sum(indx==3)>0 % If GLONASS is selected from the selection box, the following code will be executed.
% Build the directory string for GLONASS
dirStr = sprintf('/gnss/data/daily/2020/%03d/20g/', doy(i));
fileStr = sprintf('brdc%03d0.20g.Z', doy(i)); % Note this does not work for data set prior to 2000
cd(ftpobj, dirStr);
mget(ftpobj, fileStr, '.');
end
  댓글 수: 1
dpb
dpb 2020년 6월 25일
if nargin<3
GNSSflag = [0 0 0 0];
GNSS = {'GPS','GALILEO','GLONASS','BEIDOU'};
[indx,tf] = listdlg('ListString',GNSS);
end
Just a comment on your input processing -- if the user passes the third input argument, then the variables indx,tf are never defined and your next loop will die.
Need a default condition set so is definied for all cases.

댓글을 달려면 로그인하십시오.

답변 (1개)

dpb
dpb 2020년 6월 25일
편집: dpb 2020년 6월 26일
if nargin<3
GNSSflag = [0 0 0 0];
GNSS = {'GPS','GALILEO','GLONASS','BEIDOU'};
[indx,tf] = listdlg('ListString',GNSS);
end
if ~tf, error("No Satellite Selected. Aborting"), end % User canceled out
for i=1:days2get
for j=1:numel(indx) % for each selected satellite for each day
switch indx(j)
case 1 % If GPS is selected from the selection box, the following code will be executed.
% Build the directory string for GPS
dirStr = sprintf('/gnss/data/daily/2020/%03d/20n/', doy(i));
fileStr = sprintf('brdc%03d0.20n.Z', doy(i)); % Note this does not work for data set prior to 2000
cd(ftpobj, dirStr);
mget(ftpobj, fileStr, '.');
case 2 % If GALILEO is selected from the selection box, the following code will be executed.
% Build the directory string for GALILEO
dirStr = sprintf('/gnss/data/daily/2020/%03d/20l/', doy(i));
fileStr = sprintf('glps%03d0.20l.Z', doy(i)); % Note this does not work for data set prior to 2000
cd(ftpobj, dirStr);
mget(ftpobj, fileStr, '.');
case 3 % If GLONASS is selected from the selection box, the following code will be executed.
% Build the directory string for GLONASS
dirStr = sprintf('/gnss/data/daily/2020/%03d/20g/', doy(i));
fileStr = sprintf('brdc%03d0.20g.Z', doy(i)); % Note this does not work for data set prior to 2000
cd(ftpobj, dirStr);
mget(ftpobj, fileStr, '.');
case 4
....
end
end
Above assumes doing each day first; depending on the data storage organization it may be more efficient to swap the hierarchy of the loops and to process each satellite all days in order instead.

카테고리

Help CenterFile Exchange에서 Simulink Environment Customization에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by