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

 採用された回答

dpb
dpb 2015 年 8 月 19 日

2 投票

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 件のコメント

marta gc
marta gc 2015 年 8 月 19 日
works perfectly!! ,t prints cell how can I change that?
dpb
dpb 2015 年 8 月 19 日
Don't understand the question, sorry...give more details, example of problem and what want instead...
marta gc
marta gc 2015 年 8 月 19 日
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 2015 年 8 月 19 日
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.
marta gc
marta gc 2015 年 8 月 21 日
thanks, after all i used, x1=cellfun(@str2double, t); because works more quickly
dpb
dpb 2015 年 8 月 21 日
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.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File Exchange で Data Type Conversion についてさらに検索

タグ

質問済み:

2015 年 8 月 19 日

コメント済み:

dpb
2015 年 8 月 21 日

Community Treasure Hunt

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

Start Hunting!

Translated by