How I can get the data that meets the condition strcmp

1 view (last 30 days)
Hi! this is my script , I need to get the data in the column that meet the condition strcmp , the code did because he had multiple data for a single moment and I just wanted a fact by now. Then I used strcmp to see who had the same time and make the average of the data in the corresponding rows. The code works fine , so do not do is take now because the moments where there were equal.
as you can see in the picture the area marked in red are the moments there are several rows that time , I use the strcmp command to take the rows where this column matches and be able to average the data. Now I need to get the data in that column that matches No 6 but one. in this example would be made to return me a column where the following data appear: 57204.001388888886 57204.012499999997 .... etc
thanks

Accepted Answer

dpb
dpb on 19 Aug 2015
First, I'd convert the column from string to numeric and then to get the unique values of the time vector, simply use unique
t=unique(x(:,1)); % where 'x' is the data array as numeric entity
  6 Comments
marta gc
marta gc on 21 Aug 2015
thanks, after all i used, x1=cellfun(@str2double, t); because works more quickly
dpb
dpb on 21 Aug 2015
Fine, whatever works; generally one doesn't notice the overhead when reading the file and using cell2mat there to wrap textscan so I'd never checked on alternates. Of course, I'm almost completely limited to just "toy" problems here on forum or cs-sm these days having retired from the consulting gig so don't often see large files where it would be noticeable.

Sign in to comment.

More Answers (0)

Categories

Find more on Data Type Conversion in Help Center and File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!