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

1 Ansicht (letzte 30 Tage)
Hamza Naeem
Hamza Naeem am 4 Mai 2019
Kommentiert: Hamza Naeem am 4 Mai 2019
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.

Akzeptierte Antwort

John D'Errico
John D'Errico am 4 Mai 2019
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.

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Conversion finden Sie in Help Center und File Exchange

Tags

Noch keine Tags eingegeben.

Community Treasure Hunt

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

Start Hunting!

Translated by