I need help to convert ascii data matrices to complex data matrices
显示 更早的评论
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
回答(2 个)
Walter Roberson
2011-11-18
cellfun(@(C) str2double(C(1:end-3)), YourCell)
Andrei Bobrov
2011-11-18
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)
类别
在 帮助中心 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!