Convert a number to a vector

조회 수: 18 (최근 30일)
monica garcia
monica garcia 2016년 3월 13일
댓글: monica garcia 2016년 3월 13일
I'm working on a code that coverts ASHRAE refrigerant numbers to a chemical formula. I'm trying to convert a number ex: 123 to a vector [1 2 3] (from there the code falls into place). I've looked at this board with a similar question and copying and pasting the codes doesn't look the same for me. The comenters posted this code num2str(1234)*1+'0' => [1, 2 ,3, 4] but when I post the same code with a cleared command window I get the following;
num2str(1234)*1+'0'
ans =
97 98 99 100
  댓글 수: 2
Roger Stafford
Roger Stafford 2016년 3월 13일
You need to make it clear whether you are dealing with strings of characters or numerical values.
monica garcia
monica garcia 2016년 3월 13일
It's supposed to be numerical values.

댓글을 달려면 로그인하십시오.

채택된 답변

Image Analyst
Image Analyst 2016년 3월 13일
The commenters were wrong, or you transcribed it with an error. The plus should be a minus:
out = num2str(1234) - '0'
  댓글 수: 1
monica garcia
monica garcia 2016년 3월 13일
Thank you very much, this fixed it right up.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Chemistry에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by