Info

La pregunta está cerrada. Vuélvala a abrir para editarla o responderla.

making the string into a matrix

1 visualización (últimos 30 días)
Valeria Chacon
Valeria Chacon el 27 de Oct. de 2016
Cerrada: MATLAB Answer Bot el 20 de Ag. de 2021
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 comentario
Walter Roberson
Walter Roberson el 27 de Oct. de 2016
Editada: Walter Roberson el 27 de Oct. de 2016
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 ?

Respuestas (1)

KSSV
KSSV el 27 de Oct. de 2016
n = 1234509876 ;
iwant = sscanf( sprintf( '%u', n ), '%1d' )'

La pregunta está cerrada.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by