m文件找到元素(文本)合金
2视图(30天)
显示旧的评论
我需要一个MATLAB的m文件找到合金元素及其比例。输入和输出如下表所示:
![](http://www.tatmou.com/matlabcentral/answers/uploaded_files/357307/image.png)
例如输入“Al0.1
有限公司
0.25
铜
14
然后代码给输出:
![](http://www.tatmou.com/matlabcentral/answers/uploaded_files/357310/image.jpeg)
如果你还需要其他信息请让我知道。
最好的
m . Vaghari
接受的答案
Stephen23
2020年9月7日
> > str =“Al0.1Co0.25Cu14AaBb”;
> >(垫、spl) = regexp (str,“[a - z] [a - z] *”,“匹配”,“分裂”);
vec = > > str2double (spl(2:结束));
vec (isnan > > (vec)) = 1
vec =
0.1000 0.2500 14.0000 1.0000 1.0000
> >垫
垫=
“基地”“有限公司”“铜”“Aa”“Bb”