How to extract two repeated toggling data from two fixed channel using MATLAB

3 views (last 30 days)
Hi Friends,
I have a text file looks like below
Time 20.20
Channel SVID
01 5
02 7
03 1
Time 20.40
same sequence...
Time 20.60
01 1
02 7
03 5
Time 20.80
01 1
02 7
03 --
.......
As you can see in the 3rd time interval my satellite number 1 and 5 swap to channel
01 and 03. Earlier I was extracting data through channel wise using index method because
all channel and time will be repeating after particular sequence. But when I was extracting data
let say through channel 01 means actually I am taking two satellite id value 5 and 1.But again at time 20.80
satellite 05 is missed. So if I plot accordingly channel then I can not know what time my satellite 05 became invisible and giving me wrong information
about that satellite. I want to exactly what time it missed. If at all it is not missed but switching to different channel then how to extract data .
My channel sequence is fixed.
I extracted data using
fid=fopen('testingGPS.txt','r');
xdata=textscan(fid,'%s','delimiter','\n');
ydata=xdata{1};
zdata=ydata(4:24:end,:);%GPS-Channel-05
kdata=ydata(20:24:end,:);%SBAS-Channel-01
But as I said my plot giving me wrong information.
No logic is working at this moment.
Any help is highly appreciated
Thanks
POKA

Answers (1)

fbaillon
fbaillon on 7 Aug 2017
If I understand your question correctly, you can write something like that:
fid=fopen('testingGPS.txt.txt','r');
xdata=textscan(fid,'%s','delimiter','\n');
ydata=xdata{1};
ydata=cellfun(@(x) strrep(x,'--','0'),ydata,'UniformOutput',false);
iD=1;
for iL=2:4:length(ydata)
zdata(iD,:)=sscanf(ydata{iL},'%d %d');%GPS-Channel-05
kdata(iD,:)=sscanf(ydata{iL+2},'%d %d');%SBAS-Channel-01
iD=iD+1;
end
fclose(fid);
%
zdata=zdata(:,2);
kdata=kdata(:,2);
%
  2 Comments
POKA
POKA on 7 Aug 2017
Edited: POKA on 7 Aug 2017
Hi,
It is showing error
Subscripted assignment dimension mismatch in the line .
zdata(iD,:)=sscanf(ydata{iL},'%d %d')
% In short I want to say that ,let say there are 3 channel and
3 inputs are there.Inp-1,inp-2,inp-3. These inputs are coming through these
3 channel at particular time. Now these input may change their channel at
different time.Again input may not coming to channel during any time.
Now I want to check whether (say inp-1 corresponding to sv id) was present
throughout the test time. No matter in which channel appears.
At the same time in which time input was not appearing. So I want to extract only input
1 from these channel and plot them over time.
Hope my sentences makes some meaning now.

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!