dlmread

조회 수: 7 (최근 30일)
Frank
Frank 2011년 11월 22일
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
Fangjun Jiang
Fangjun Jiang 2011년 11월 22일
Use {}Code format next time.

댓글을 달려면 로그인하십시오.

채택된 답변

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

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Mathematics에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by