How to generate sequences from matrix
Show older comments
Hi,
I'm very new on Matlab and i have a problem with an exercise. I have this matrix :

The first column represent the time in secondes and the second column represent the data measured. The data should be measured each 1 secondes, but sometimes lines of data are not measured in a correct time (like 2.1 and 5.8). So I have to write a procedure which find sequences of data measured in the correct time and put it in a table. Example:
With this matrix we have 3 good sequences :
1
3, 4, 5
7, 8, 9, 10
So the table should be :

Edit - This is what I did until now :
V = [1.0000 2.1000 3.0000 4.0000 5.0000 5.8000 7.0000 8.0000 9.0000 10.0000];
r=find(V(2:length(V))-V(1:length(V)-1)~=1);
V(r(2:2:end))=[]
So i could identify the wrong values and deleted it, but now my problem is to make the table i showed before.
Edit - To make the table, i tried something like this :
V=[1.0000 3.0000 4.0000 5.0000 7.0000 8.0000 9.0000 10.0000];
r=find(diff(V)~=1)
S1=V(1:r(1))
S2=V(r(1)+1:r(2))
S3=V(r(2)+1:end)
Now i can separated each sequences of the vector, but i can't find a solution to organise it in a table.
2 Comments
John D'Errico
on 19 Sep 2016
Edited: John D'Errico
on 19 Sep 2016
So why not make an effort? Do some reading. I'll give you a hint: you probably want to do interpolation, so interp1 might help you. When you actually have a question about MATLAB, then ask it. But make an effort. Show what you have tried, and what went wrong.
José-Luis
on 19 Sep 2016
Accepted Answer
More Answers (0)
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!