如何将[12 25 34 466 55]
转换为字符串数组['12' '25' '34' '466' '55']
?我知道的转换函数将该数组转换为表示整个数组的一个字符串。Matlab:将数组转换为字符串数组
25
A
回答
26
字符串数组必须是单元格数组。这就是说:
s = [12 25 34 466 55]
strtrim(cellstr(num2str(s'))')
0
在MATLAB中,[ '12' '25' '34' '466' '55']是相同的含这些数字单个字符串。这就是说:
['12' '25' '34' '466' '55']
ans =
12253446655
我需要在这里为你正在尝试什么来完成,但假设你希望仍然能够访问每个个体数作为一个字符串更多上下文,单元阵列可能是最好的办法你可以采取:
A = [1 2 3]
num2cell(num2str(A))
(当然,你仍然必须移除俺们杂散空格)
+0
即使您删除了杂散空格,您最终也会得到一个单独的字符串数组,其中包含每个数字。改为交换'num2cell'和'num2str'的顺序。 'cellfun(@ num2str,num2cell(s),'UniformOutput',false)'很好地完成了工作。 – Doresoom
10
7
现在MATLAB 2016B后,你可以简单地使用
s = [12 25 34 466 55];
string(s)
相关问题
- 1. 转:将字符串数组转换为Json数组字符串
- 2. 将字符串数组转换为字符串数组
- 3. 将转换为字符串的数组转换回数组
- 4. 注意:数组到字符串转换将数组转换为字符串
- 5. 将json转换为数组php将数组转换为字符串转换
- 6. 将字符串数组转换为字符数组
- 7. Python:如何将字符串数组转换为数组数组?
- 8. 将数组数组转换为angularjs中的字符串数组
- 9. 将字符串转换为int数组
- 10. MongoDB将字符串转换为数组
- 11. 将PHP字符串转换为数组
- 12. 将javascript字符串转换为数组
- 13. 将字符串转换为json数组
- 14. 将数组转换为字符串Javascript
- 15. 将数组转换为字符串Nesc
- 16. 将字符串转换为数组(android)
- 17. 将数组值转换为字符串
- 18. PHP将字符串转换为数组
- 19. 将Python数组转换为字符串
- 20. 将int转换为字符串数组
- 21. 将JSONArray转换为字符串数组
- 22. PHP:将数组转换为字符串?
- 23. JS将字符串转换为数组
- 24. 将字符串数组转换为ImageButton
- 25. 将字符串转换为数组
- 26. 将Dictionary.keyscollection转换为字符串数组
- 27. 将数组转换为字符串
- 28. 将php字符串转换为数组
- 29. 将array.description字符串转换为数组
- 30. 将字符串转换为int数组
一种更好的方式比我上面写的。 – Vish
这比arrayfun和cellfun快两倍。 +1 – Doresoom