Matlab String (1000) conversion into (1 0 0 0)

Hy my question is that I have a string like x = 1000 I want to convert it into matrix like 1 0 0 0. Can you please guide me how to convert it.

 采纳的回答

Is x a character vector, or a string vector? If char, do this:
x = '1000';
y = x - '0';
If a string, you could simply convert to character. Thus,
x = "1000";
y = char(x) - '0';
Other ways I am sure.

更多回答(0 个)

类别

在 帮助中心 和 File Exchange 中查找有关 Characters and Strings 的更多信息

标签

尚未输入任何标签。

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by