Borrar filtros
Borrar filtros

Str2num error

5 visualizaciones (últimos 30 días)
Naoki Ishibashi
Naoki Ishibashi el 9 de Sept. de 2016
Comentada: Naoki Ishibashi el 10 de Sept. de 2016
I am getting the following error:
Error using str2num
Too many input arguments.
Error in b (line 8)
daystr = str2num(i,'%o');
Here is the portion of the code:
numFiles = 31;
startRow = 1;
endRow = inf;
myData = cell(1,numFiles);
for i = 0:numFiles
if i<10
daystr = ['0', str2num (i)];
else
daystr = str2num(i);
end
filename = ['TS2004.07.',daystr,'.00','.txt'];
mtx(i) = load(filename);
end
I want to load all text files, 'TS2004.07.0000.txt' to 'TS2004.07.3100.txt'.

Respuestas (2)

the cyclist
the cyclist el 10 de Sept. de 2016
Editada: the cyclist el 10 de Sept. de 2016
Don't leave a space between the function name and the parentheses. Also, I think you meant to use num2str here, not str2num. Try
num2str(i)

Naoki Ishibashi
Naoki Ishibashi el 10 de Sept. de 2016
Thank you, I solve one error to change num2str(i), but I still have one problem in following,
mtx(i) = load(filename);
I want to put each data into mtx(0) to mtx(31)
  2 comentarios
Walter Roberson
Walter Roberson el 10 de Sept. de 2016
You cannot index a structure at index 0. You will need to add 1, so
mtx(i+1) = load(filename);
See also
Naoki Ishibashi
Naoki Ishibashi el 10 de Sept. de 2016
Thank you so much, I solve my problem.

Iniciar sesión para comentar.

Categorías

Más información sobre Characters and Strings en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by