Borrar filtros
Borrar filtros

Read text file and store in .mat file

4 visualizaciones (últimos 30 días)
Sudharsan
Sudharsan el 24 de Ag. de 2013
Comentada: dpb el 28 de Dic. de 2016
Assume i have the following values in a text file.
102
103
43.
i want to read this text file and store in a .mat file so that i can access the array of value.

Respuesta aceptada

dpb
dpb el 24 de Ag. de 2013
data=importdata('yourfile.txt');
Use the data as is...
doc save % and friends to write/read .mat files...
If the data in the text file contain more formatting, etc., than just the simplest, then
doc textscan % and friends
help iofun
will give a list of all the choices (a veritable plethora from which to choose depending on what you have as the input format).
  4 comentarios
shuchita bahadur
shuchita bahadur el 28 de Dic. de 2016
when usinf importdata in Command line it works, not from within a script. The variable does'nt show in workspace.
dpb
dpb el 28 de Dic. de 2016
In a script is the same as at the command line. If you mean a function m-file, yes, variables are local in scope within functions; to return the variable to the calling scope (command line or calling function), that function must have a return variable and the result of the read operation, whatever routine you use, returned to the caller via that variable.
See
doc function
for how functions work...

Iniciar sesión para comentar.

Más respuestas (1)

dwarose
dwarose el 24 de Ag. de 2013
etc., than just the simplest, then doc textscan % and friends help iofun will give a list of all the choices (a veritable plethora from which to choose depending on what you have as the input formatUse the data as is... doc save % and friends to write/read .mat files... If the data in the text file contain more formatting, http://justintv-fenerbahce-eskisehirspor-maci-canli-seyret.blogs.lalibre.be/

Categorías

Más información sobre Text Data Preparation 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