MATLAB: How to import data from attatched csv file

csvMATLABmatlab functionreadtabletable

In the attatched csv file there is a lot of clutter other than data, first 11 lines are not needed, so I used
T=readtable('data.csv','HeaderLines',11);
but in the data also, every data point has its unit GHz attached to it, which I dont want to import into my array, how can I stop that GHz from being imported. What more lines of code needs to be added. For ex: output from above readtable function is :
Var1 Var2
_____________ ______
{'1.000 GHz'} 200
{'1.100 GHz'} 200
{'1.200 GHz'} 200
{'1.300 GHz'} 200
{'1.400 GHz'} 200
{'1.500 GHz'} 200
{'1.600 GHz'} 199.99
{'1.700 GHz'} 199.99
{'1.800 GHz'} 199.99
{'1.900 GHz'} 199.99
{'2.000 GHz'} 199.99
It is taking var1 as string because of the presence of GHz, please someone help me remove that. Also explain how can I name change names of these var1 and var2 by using appropritae argument is readtable function.
I noticed another problem, in the var2 column the data is till 3 decimal places, but imported data is automatically rounded off to 2 decimal place, i don't want it to be rounded off. How to avoid that?
Thankyou in advance.

Best Answer

You could try using the Format name-value pair. You might need to read about it in textscan for the specifics of how it works. This allows you to specify the format of the delimited values in each row.
Space gets treated as a delimiter here. Since there is a space between the number and GHz, it can be read in independent of the number and actually be ignored. Since we don't have your csv, I can't test it for your data, but try somethign like this.
T=readtable('data.csv','HeaderLines',11,"Format",'%f%*s%f')
From the sample data you shared, this is the result I get.
T =
Var1 Var2
____ ______
1 200
1.1 200
1.2 200
1.3 200
1.4 200
1.5 200
1.6 199.99
1.7 199.99
1.8 199.99
1.9 199.99
2 199.99