필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

making the string into a matrix

조회 수: 1 (최근 30일)
Valeria Chacon
Valeria Chacon 2016년 10월 27일
마감: MATLAB Answer Bot 2021년 8월 20일
N=length(str);
count=1;
for k=1:N
m=str2double(str(k));
if isnan(m)==0
str(count)=k;
count=count+1;
numbers = cell2mat(sscanf((str),'k'))
disp(m)
end
end
this is currently the code I have "str" is the number inputted by the user, however my code isn't working. If the user were to input: 1234509876 then I would want the outcome to be numbers=[1,2,3,4,5,0,9,8,7,6]; what can I do?
  댓글 수: 1
Walter Roberson
Walter Roberson 2016년 10월 27일
편집: Walter Roberson 2016년 10월 27일
How do you intend to hand the case where the user asks for 0 as the first entry? For example if the user asks for 007 then how do you intend to tell the difference compared to if they had just asked for 7 ?

답변 (1개)

KSSV
KSSV 2016년 10월 27일
n = 1234509876 ;
iwant = sscanf( sprintf( '%u', n ), '%1d' )'

이 질문은 마감되었습니다.

태그

Community Treasure Hunt

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

Start Hunting!

Translated by