MATLAB Answers

alway get an error when i use a load command

5 views (last 30 days)
Ray
Ray on 8 Dec 2015
Answered: Image Analyst on 8 Dec 2015
% 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 Comments

Sign in to comment.

Answers (3)

Image Analyst
Image Analyst on 8 Dec 2015
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 Comments

Sign in to comment.


Daniel LaCroix
Daniel LaCroix on 8 Dec 2015
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 Comments

Sign in to comment.


Geoff Hayes
Geoff Hayes on 8 Dec 2015
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 Comments

Sign in to comment.

Tags


Translated by