Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

How to check the inputs of a user given vector

조회 수: 3 (최근 30일)
Nathan Jalal
Nathan Jalal 2020년 6월 25일
마감: MATLAB Answer Bot 2021년 8월 20일
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개)

Sayyed Ahmad
Sayyed Ahmad 2020년 6월 25일
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