Loading data from excel-file ignoring string values

I have an Excel file containing strings and doubles. I only want to import the numeric data into matlab while ignoring the strings because i want to use the function fit.
Fit doesnt function when there are "NaN" values. So how do i get around those? I thought about skipping the rows containing the NaN values or simply ignore them but i dont know how since the strings arent consecutive.
here is a shortened example of a column i want to import
Schubspannung
[Pa]
15,317
15,285
15,082
14,95
14,841
14,765
Schubspannung
[Pa]
14,699
44,015
53,717
61,447
68,44
75,16
81,828
88,07
94,662
101,34
107,31
113,27
119,33
125,6
131,5
137,3
142,86
148,51
153,93
159,14
163,94
168,13
172,88
177,18
181,44
185,18
188,43
191,48
194,63
212,57
Schubspannung
[Pa]
198,73
199,81
200,39
200,84
201,45
201,86
202,11
202,51
203,11
203,33
203,66
204,31
204,57
204,78
205,22
205,6
205,59
205,76
206,2
206,37
206,21
206,51
206,7
207,01
207
206,98
207,27
207,28
207,13
207,24
207,27
207,51
207,93
208,19
208,17
208,08
208,04
208,12
208,46
208,68
208,98
208,75
208,83
209,16
208,96
209,39
209,64
209,32
209,49
209,61
208,97
209,31
209,62
209,49
209,35
209,25
209,46
209,54
209,5
209,63

 Akzeptierte Antwort

Walter Roberson
Walter Roberson am 4 Apr. 2021
filename = 'AsAppropriate.xlsx';
C = convertStringsToChars( readcell(filename) );
mask = cellfun(@ischar, C);
C(mask) = str2double( regexprep(C(mask), ',', '.', 'once') );
M = cell2mat(C);
M = rmmissing(M);

Weitere Antworten (0)

Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by