MATLAB: How to scan text

arrayMATLABtextscan

on those files:
on the 5th line there [are these] data:
# Number of frequencies : 8 (2, 4, 6, 8, 10, 12, 14, 16 GHz)
# Number of frequencies : 4 (4, 8, 12, 16 GHz)
i need to create a vector with those values i tried to locate the number 8 or 4 using textscan and to make a for loop n times to get those integers, but it didn't work, maybe there is something with the (,)
any suggestions?

Best Answer

The frequencies are integers in the third column. This code works for the first file and should work for both:
fidi = fopen('rectTE_8f.exp');
d = textscan(fidi, '%d%d%d%f%f%f%f', 'Headerlines',10, 'Delimiter','\n','CollectOutput',1);
frqs = d{1}(:,3);
The ‘frqs’ variable is your vector of frequencies.
If you want a vector of only the frequencies on the 5th line, you can get them easily enough with:
ufrqs = unique(frqs);
It will give you a vector of the unique frequencies in the vector.
Related Question