dlmread

7 Ansichten (letzte 30 Tage)
Frank
Frank am 22 Nov. 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 Kommentar
Fangjun Jiang
Fangjun Jiang am 22 Nov. 2011
Use {}Code format next time.

Melden Sie sich an, um zu kommentieren.

Akzeptierte Antwort

Fangjun Jiang
Fangjun Jiang am 22 Nov. 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 Kommentare
Frank
Frank am 29 Nov. 2011
Does anybody have any idea what the heck is wrong with my dlmread--that is where it chokes!!!!!
Walter Roberson
Walter Roberson am 29 Nov. 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 .

Melden Sie sich an, um zu kommentieren.

Weitere Antworten (0)

Kategorien

Mehr zu Mathematics finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by