Get numerical data from a string with multiple kinds of delimiters
Show older comments
I have a text file (with very strange formatting) where each row is printed as
{2, 3} -> {-0.003201472132661235 + 0.00011724512961300188*I, 0.0024489343681961366 + 0.0012251936705803077*I,....}
This is very messy - let me clarify
The numbers 2 and 3 are indices. At point (2,3) we have a list of complex numbers where I = sqrt(-1). I'd like to translate this string into the row of a matrix formatted as
[2, 3, -0.00320+0.0001172i, 0.0024489+0.001225i, ...]
I have tried load / csvread but obviously not the right functions. Currently I am using fopen, reading each line with fgets, and then strtok repeatedly but this is going badly.
Do you have any suggestions? I would be most appreciative of your input.
Thanks!
PS these files can be North of 14MB so a real pain, too.
Accepted Answer
Categories
Find more on String Parsing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!