alway get an error when i use a load command
1 次查看(过去 30 天)
显示 更早的评论
% i made sure that the .mat files are in the same directory the myFolder directory specified below. The code was working fine but i upgraded the software to 2015b. Is this a problem?
myFolder = '/Volumes/MY PASSPORT/redhwan/Documents/MATLAB/2DimenstionalTestingGT20150907/MeasurementDataFinal/TWDPN5db14ft_35inchMetalCab'
load('xpositions.mat');
load('ypositions.mat');
Error using load
Unable to read file 'xpositions.mat'. No such file or directory.
Error in Plot2D (line 19)
load('xpositions.mat');
0 个评论
回答(3 个)
Image Analyst
2015-12-8
Use fullfile():
fullFileName = fullfile(myFolder, 'xpositions.mat');
load(fullFileName);
I strongly recommend you don't use cd to change directory and just create the full file name using fullfile() instead. Why? See the FAQ : http://matlab.wikia.com/wiki/FAQ#Where_did_my_file_go.3F_The_risks_of_using_the_cd_function.
0 个评论
Daniel LaCroix
2015-12-8
Just making a string variable with the folder the files are in doesn't help. You need to actually change the directory in MATLAB. You can do this with the cd command. However, if the program isn't in that folder you may get problems when you change the directory.
Another idea is to put the full file path in the load command, like this: load('/Volumes/MY PASSPORT/redhwan/Documents/MATLAB/2DimenstionalTestingGT20150907/MeasurementDataFinal/TWDPN5db14ft_35inchMetalCabxpositions.mat')
0 个评论
Geoff Hayes
2015-12-8
Ray - if the two mat file are in the directory /Volumes/MY PASSPORT/redhwan/Documents/MATLAB/2DimenstionalTestingGT20150907/MeasurementDataFinal/TWDPN5db14ft_35inchMetalCab, then verify that this directory has been added to the MATLAB search path. Use the path function to view the search path.
0 个评论
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Search Path 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!