フィルターのクリア

how to separate the figures of specific number using matlab ?

1 回表示 (過去 30 日間)
mohammad
mohammad 2014 年 6 月 12 日
コメント済み: mohammad 2014 年 6 月 14 日
How to separate the figures of specific number and then making a new vector which will include the figures that have been separated separately ?? for example : if i have a number as (123456789) , what is the function or command that will separate these figures of the number so that they look like this form 1 2 3 4 5 6 7 8 9 Meaning that will turn into a vector

回答 (2 件)

Image Analyst
Image Analyst 2014 年 6 月 12 日
Try this:
n = 123456789;
% Convert to a string.
strn = num2str(n)
% Initialize with all spaces.
output = char(32*ones(1,2*length(strn)))
% Make every other character the digits from the number.
output(1:2:end) = strn
  3 件のコメント
Image Analyst
Image Analyst 2014 年 6 月 13 日
output is a vector. It's a row vector of type character. And it stops at 9 because that's what you asked for when you said you want it to "look like this form 1 2 3 4 5 6 7 8 9". Please explain why my solution is not giving exactly what you asked for. 9 was your last digit and that's where it stopped. Where would you want it to stop at? Perhaps give a second example if that would help.
mohammad
mohammad 2014 年 6 月 14 日
i'm so sorry my friend , the mistake occurred ,your code is correct 100 percent . i have performed it in wrong way thank you very much.

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


Brian B
Brian B 2014 年 6 月 13 日
編集済み: Brian B 2014 年 6 月 13 日
Perhaps you want the characters converted back to numbers? If so, try
n=123456789
str =num2str(n)
strn = regexp(str,'\d','match')
str2double(strn)
  1 件のコメント
mohammad
mohammad 2014 年 6 月 14 日
thank you very much 'Brian'

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

カテゴリ

Help Center および File ExchangeAnnotations についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by