필터 지우기
필터 지우기

alway get an error when i use a load command

조회 수: 3 (최근 30일)
Ray
Ray 2015년 12월 8일
답변: Image Analyst 2015년 12월 8일
% 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');

답변 (3개)

Image Analyst
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.

Daniel LaCroix
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')

Geoff Hayes
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.

카테고리

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

태그

Community Treasure Hunt

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

Start Hunting!

Translated by