On Jul 30, 1:15 pm, "Sachitha Obeysekara" <sachitha.
2.obeysek...@gsk.com> wrote:
> hi,
> i have a cell array:
>
> b =
>
> T1,0,0,0,0,00256.964
> T1,0,0,0,0,00256.656
> T1,0,0,0,0,00256.869
> T1,0,0,0,0,00257.666
> T1,0,1,1,0,00246.296
> ...and so on
>
> how do i seperate out so that i have a array like this:
> c =
>
> 0 0 0 0 00256.964
> 0 0 0 0 00256.656
> 0 0 0 0 00256.869
> 0 0 0 0 00257.666
> 0 1 1 0 00246.296
> ..and so on
>
> the T1 field can be discarded
>
> Cheers
Sachitha Obeysekara:
<SNIP down to gruesome ML atrocity...
> here's what i'm using:
> regEx = '%s';
> for i = 1:(numFieldsOut-1)
> regEx = [regEx '%n'];
> end
> b=textscan(b,regEx,'delimiter',',');
> output = '[';
> for i = 2:numFieldsOut
> output = [output 'b{1,' num2str(i) '} '];
> end
> output = [output ']'];
> output = eval(output);
WHY not simply use what you were given above?!...
% some data
b={
'T1,1,20,300,4000,00256.964'
'T10,1,20,300,4000,00356.964'
'TT1,10,200,3000,40000,00456'
};
nf=5; % #floats...
% the engine
fmt=['%s',repmat('%f',1,nf)];
r=textscan(char(b).',fmt,'delimiter',',');
r=cat(2,r{:,2:end});
% the result
b
r
For some reason the last character of the first row is
combined with the first one on the second row. But that
doesn't happen on other rows.
However if I add a fourth cell, it works right, for example
Public Submission Policy
NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for
all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content.
Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available
via MATLAB Central. Read the complete Disclaimer prior to use.