Info

Questa domanda è chiusa. Riaprila per modificarla o per rispondere.

How to check the inputs of a user given vector

3 visualizzazioni (ultimi 30 giorni)
Nathan Jalal
Nathan Jalal il 25 Giu 2020
Chiuso: MATLAB Answer Bot il 20 Ago 2021
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

Risposte (1)

Sayyed Ahmad
Sayyed Ahmad il 25 Giu 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