MATLAB: Replace comma with dot in large array

guiMATLABscript

Please help, I'm new to matlab coding. I have a array like this
data={'250,1000' '-6,52796' '322,683' '1,50367'
'250,0500' '-6,54959' '322,695' '1,50379'
'250,0000' '-6,63267' '322,711' '1,50395'}
except that it is very large (4500 lines). I want to replace all the commas with dots and convert to a data matrix. So far I have this:
data = strrep(data, ',', '.');%replace ´,´ with ´.´
data=cellfun(@str2num,data);
which can do the trick but it is very slow. Any suggestions to speed up the process?

Best Answer

Well, the slow bit is probably your cellfun(@str2num). Replacing that by:
data = str2double(data);
would probably be faster. The strrep step is already as fast as it can be in matlab.
If you want faster, you need to modify your import process but if I recall correctly matlab is not very good as coping with ',' decimal separator.