dlmread
7 次查看(过去 30 天)
显示 更早的评论
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!
采纳的回答
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 个评论
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 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!