MATLAB Answers

How to check the inputs of a user given vector

1 view (last 30 days)
Nathan Jalal
Nathan Jalal on 25 Jun 2020
Edited: Nathan Jalal on 25 Jun 2020
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

Answers (1)

Sayyed Ahmad
Sayyed Ahmad on 25 Jun 2020
I hope I understand your problem. Try this
a=[0 0 1 1];
idx=find(a==1)
the answer would be:
idx =
3 4

Community Treasure Hunt

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

Start Hunting!

Translated by