|
jacob lalaounis wrote:
> Helllo,
>
> I want to read a file that has data like this.I want to make an array
> from the third colum to get the numbers and in the space to apply zero
> and where the * is to apply -1. I try to textread but it is impossible
> to manage the cell array.
>
> 5) 3 368ms
> 6) 1
> 7) 6
> 8) 1
> 9) 4
> 10) 1 *
> 11) 6 *
> 12) 1 *
> 13) 2
> 14) 1
> 15) 6 410ms
>
> For example
> [C,position] = textscan(fed, '%4s %d %q','delimiter','\t')
>
> if(C{1,3}(1:300)=='*')
>
> this if doesnt work because C is a cell array
...
Not sure I know _exactly_ what your request is and it took a couple
tries, but see if can salt following to suit...
>> [C,p] = textread('test.dat', '%*4s %d %q');
>> p(strcmp(p,'*'))={'-1'};
>> p(strcmp(p,''))={'0'};
>> p
p =
'368ms'
'0'
'0'
'0'
'0'
'-1'
'-1'
'-1'
'0'
'0'
'410ms'
>>
--
|