在matlab中将字符串转换为数字数组 [英] convert string to number array in matlab

查看:345
本文介绍了在matlab中将字符串转换为数字数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个输入一串数字的脚本

I have a script in which a string of number is entered

string='123'

string='9823'

我正在尝试将其转换为 [a,b,c,d] 形式的数组例如从一串 '123' 到一个数值数组 [1,2,3]

I am trying to convert this into an array of the form [a,b,c,d] e.g from a string of '123' to a numerical array [1,2,3]

有关如何执行此操作的任何提示?

Any tips on how to do this?

推荐答案

str = '123';
num = str - '0';
% num = [1 2 3];

这篇关于在matlab中将字符串转换为数字数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆