I need help to convert ascii data matrices to complex data matrices
Show older comments
Dear All,
I need some help to convert data stored in a file that is in ascii format. The data I have looks like as below:
{{'1930+5263i<E>' '3930+5563i<E>' '1930+5263i<E>' '3930+5563i<E>'} {'1930+5263i<E>' '3930+5563i<E>' '1930+5263i<E>' '3930+5563i<E>'}}
What I want to do is convert this to a cell matrix containing of matrix whis in turn contain of complex valued data as given below:
{[1930+5263i 3930+5563i 1930+5263i 3930+5563i] [1930+5263i 3930+5563i 1930+5263i 3930+5563i]}
I have tried to do a parser based on state machine that remove '<E>' but I stucked in my mind so I wonder if there is some simple method to do that with matlab commands.
Thanks and all the best,
Michael Numminen
Answers (2)
Walter Roberson
on 18 Nov 2011
cellfun(@(C) str2double(C(1:end-3)), YourCell)
Andrei Bobrov
on 18 Nov 2011
z ={{'1930+5263i<E>' '3930+5563i<E>' '1930+5263i<E>' '3930+5563i<E>'} {'1930+5263i<E>' '3930+5563i<E>' '1930+5263i<E>' '3930+5563i<E>'}}
cellfun(@(x)str2double(regexprep(x,'<E>','')),z,'un',0)
Categories
Find more on Data Type Conversion in Help Center and File Exchange
Products
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!