Converting a string array into a number array

Please how can l convert '123456789' to [ 1 2 3 4 5 6 7 8 9] in MATLAB

 採用された回答

KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 13 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 13 日

0 投票

#Edited
num_str='123456789'
num_str - '0'
Result:
ans =
1 2 3 4 5 6 7 8 9

7 件のコメント

dzix design
dzix design 2021 年 2 月 13 日
Thanks sir 🙏🏼. You just saved me much time in a coding problem
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 13 日
Weocome @dzix design I'm glad it helped
dzix design
dzix design 2021 年 2 月 13 日
May l have your WhatsApp number Sir?
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 13 日
編集済み: KALYAN ACHARJYA 2021 年 2 月 13 日
Available in the profile description, but I rarely reply to unknown.
:)
Jan
Jan 2021 年 2 月 13 日
The is no reason to apply num2str(), when the variable is a CHAR vector already. Easier:
num_str = '123456789'
result = num_str - '0'
KALYAN ACHARJYA
KALYAN ACHARJYA 2021 年 2 月 13 日
Yes sir @Jan Thanks, In day time, I have answered a similar question, which first required changing num2str, so I used it here by mistake.
Your teaching is very valuable, thank you and much appreciation
dzix design
dzix design 2021 年 2 月 13 日
@jan thanks 🙏🏼

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

ヘルプ センター および File ExchangeCharacters and Strings についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by