dlmread

7 visualizaciones (últimos 30 días)
Frank
Frank el 22 de Nov. de 2011
I've created, by concatenating inputs from the user, a path to files on my computer that contain data I want to read into matlab. Example:
pt = input('Enter number:','s')
run = input('Enter run number','s');
task = input('What task?','s');
run_task = strcat(run,'_',task)
pt_plus_run = strcat(pt,'_',run)
main_path='C:\XXXXX\XXXX_ XXXX\XXX_ files',
path_to_data=strcat(main_path,'\',pt,'\',pt_plus_run,'\',pt_run_task)
data=dlmread(path_to_data,',', [1 2 -1 7])
It is at the dlmread statement that the code chhkes. Can I use a concatentated string variable in dlmread?
Thanks for your help!
  1 comentario
Fangjun Jiang
Fangjun Jiang el 22 de Nov. de 2011
Use {}Code format next time.

Iniciar sesión para comentar.

Respuesta aceptada

Fangjun Jiang
Fangjun Jiang el 22 de Nov. de 2011
Check the help of dlmread(). I believe the range [R1, C1, R2, C2] won't allow negative number.
use fullfile() instead of strcat() to combine path and file name.
  19 comentarios
Frank
Frank el 29 de Nov. de 2011
Does anybody have any idea what the heck is wrong with my dlmread--that is where it chokes!!!!!
Walter Roberson
Walter Roberson el 29 de Nov. de 2011
exist('whole_sensor_data_file_path','file')
should be
exist(whole_sensor_data_file_path,'file')
The whole_sensor_data_file_path you construct includes pt_run_task so it includes .csv at the end. But then you assign whole_sensor_data_file_path to PathStr and you assign pt_run_task to FileName and then you fullfile() together the combination of the two. That is going to add the file name string complete with .csv on to the end of a string that already includes all of that. The name that gets constructed will not be something you can open .

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Mathematics 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!

Translated by