Matlab how to extract a number from a particular string [] measured success

Only as a learning record, Gangster skip.

bluetoothread='#-0.115000*-0.205000##-0.115000*-0.175000##-0.115000*-0.155000#;

Bloggers extracts the character '#' and ' ' between the data [Note, not including the extracted 'and data between the' # ']

------------------------------
bloggers find extractBetweenfunction is not supported in matlab2016a and earlier, preferably with more than matlab2017a the version in order to use this function.

——————————————————————————————

Step:
. 1, extractBetween - (extractBetween cell type data is obtained)
2, cell2mat - cell converted to char Note! A transfer cycle requires a char, and a char is converted into a num, num final and then each structured in an array
3, str2double

code show as below:

clear;close all;clc;
bluetoothread='#-0.115000*-0.205000##-0.115000*-0.175000##-0.115000*-0.155000#;

s=extractBetween(bluetoothread,'*','#')
s=s'
j=1;
for i=1:length(s)
    smat=cell2mat(s(i))
    snum=str2double(smat)
    snumm(j)=snum
    j=j+1;
end

Here Insert Picture Description

After running as shown:
Here Insert Picture Description

-----------------------------------
reference
Portal
Here Insert Picture Description
Portal 2
Here Insert Picture Description

Published 71 original articles · won praise 9 · views 6562

Guess you like

Origin blog.csdn.net/weixin_41529093/article/details/103554342