How I can get the data that meets the condition strcmp

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

 Réponse acceptée

dpb
dpb le 19 Août 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 commentaires

works perfectly!! ,t prints cell how can I change that?
dpb
dpb le 19 Août 2015
Don't understand the question, sorry...give more details, example of problem and what want instead...
I need work with the t's result but i can't work if t is a cell. But i solved with cell2mat
dpb
dpb le 19 Août 2015
Or, address cell content with the curly brackets. But, I generally do the conversion directly upon reading the data unless there's a specific reason one needs to retain a cell array. It's an issue with such functions such as textscan that can't return an array whether one is need or not; I almost always will wrap that call inside cell2mat to eliminate it from the git-go; then can go on your business directly.
thanks, after all i used, x1=cellfun(@str2double, t); because works more quickly
dpb
dpb le 21 Août 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.

Connectez-vous pour commenter.

Plus de réponses (0)

Tags

Question posée :

le 19 Août 2015

Commenté :

dpb
le 21 Août 2015

Community Treasure Hunt

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

Start Hunting!

Translated by