Hi matlab gurus
I have a tricky question that I just can't "for loop" around. I have to make a program that can read an csv document containing alot of data. (Groundwaterlevel readings pr 5 min, over 2 years) "Its not important but now you know".
the csv file comes with two columns pr "reading equipment", and that can range from 1 to 20. So an example would be 4 measuring equipments, gives 8 columns.
The first column in the pair is the time and the second is the measurements. Thats why I have made the format for the textscan as:
formatSpec = '%{dd-MM-y HH:mm}D%q%[^\n\r]';
This is an example of 1 measuring equipment data set. But if there where two it would be:
formatSpec = '%{dd-MM-y HH:mm}D%q%{dd-MM-y HH:mm}D%q%[^\n\r]';
And so on...
I've found out that if I put a * in front of the columns of example measuring equipment 1:
formatSpec = '%*{dd-MM-y HH:mm}D%*q%{dd-MM-y HH:mm}D%q%[^\n\r]';
The textscan only gives me the data from the secound column which is nice. But here is where I have my troubles.
I need a code that can first measure how many measuring equipments there are: Easy length(data,2)/2 = number of measuring equipments.
But then I need a code that can produce the formatSpec so that if its 1
formatSpec = '%{dd-MM-y HH:mm}D%q%[^\n\r]';
2:
formatSpec = '%{dd-MM-y HH:mm}D%q%{dd-MM-y HH:mm}D%q%[^\n\r]';
3:
formatSpec = '%{dd-MM-y HH:mm}D%q%{dd-MM-y HH:mm}D%q%{dd-MM-y HH:mm}D%q%[^\n\r]';
and so on......
The second part I need to fix is that a user can choose which of the measuring equipments he wants the data from, for as an example there are 4 measuring equipments, so first the program reads that there are 4, and set the textscan to use a formatSpec for 4 inputs, secondly he chooses the 3 measuring equipment so the formatSpec will look like this:
formatSpec = '%*{dd-MM-y HH:mm}D%*q%*{dd-MM-y HH:mm}D%*q%{dd-MM-y HH:mm}D%q%*{dd-MM-y HH:mm}D%*q%[^\n\r]';
How do I make a code that can do that?