input comma separated values to a matrix
8 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
I need a shove in the right direction:
How do I ask the user for some numerical values that are separated by a comma? For example "Enter the numbers, separated by a comma"
Then the user would enter "1,2,3" and these numbers would go into a matrix
Second question: There isn't a go to statement in Matlab, right?
0 comentarios
Respuesta aceptada
Chandra Kurniawan
el 2 de Dic. de 2011
Of course it can be done.
clear; clc;
answers = input('Enter the numbers, separated by a comma : ','s');
str = regexprep(answers,',',' ');
num = str2num(str)
And about go to statement, Matlab don't have go to statement.
2 comentarios
Robert Cumming
el 2 de Dic. de 2011
You could also use
num = strread ( answers, '%f', 'delimiter', ',' );
Más respuestas (0)
Ver también
Categorías
Más información sobre Logical en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!