Solving for mean from a file imported to matlab
2 次查看(过去 30 天)
显示 更早的评论
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 个评论
Walter Roberson
2013-11-22
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
回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Whos 的更多信息
产品
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!