Solving for mean from a file imported to matlab
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
In a file that is formatted like
18.6-37.4-48.9-66.8-82.0-94.4 valid
19.2-32.7-47.0-68.2 valid
18.9-37.7-49.0-68.1-82.6-93.8 valid
24.5-33.3-51.7-64.4-83.3 valid
23.6-39.9-50.1-68.8-80.9-91.5-107.0 corrupted
I am having trouble extracting the numbers from each line of code (amount of lines is in the hundreds) and finding the mean of all numbers. I have attempted to open the file and then use a while loop with a regexp function to draw out all the numbers and then convert the class back to double using str2num (still in the while loop) however when I attempt to use function sum or mean at any given point it says it cannot convert class cell with those functions.
1 Kommentar
Walter Roberson
am 22 Nov. 2013
Do the dashes represent negative signs? What if a number in the middle is positive instead: will there be a + sign or will there be a space?
The number of values on each line differs, right?
Please show your existing code. I know you are able to get some input values because that was shown to you in http://www.mathworks.co.uk/matlabcentral/answers/106962-searching-for-numbers-above-a-certain-threshold
Antworten (0)
Siehe auch
Kategorien
Mehr zu Argument Definitions finden Sie in Help Center und File Exchange
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!