필터 지우기
필터 지우기

error when using addpath (mac user)

조회 수: 9 (최근 30일)
Renee
Renee 2013년 11월 8일
댓글: Renee 2013년 11월 10일
Hello,
I am trying to import data from excel into matlab using xlsread and xlsfinfo. It was working while I had the excel file in the MATLAB folder, but now that I've moved it to a different folder it doesn't work unless I go into the folder using Matlab's Current Folder Window, select the folder and then select Add to Path -> Selected Folders and Subfolders.
The excel file I would like to import data from is called 'Cell tracks summary - micrometres.xlsx'.
If I drag this file into terminal I get the path: /Volumes/Hard\ Drive\ 2/PhD\ Results/Excel\ Spreadsheets/Cell\ tracks\ -\ Transplantations/Bipolar\ phase/Cell\ tracks\ summary\ -\ micrometres.xlsx
I have tried adding the above into the search path using addpath: addpath('/Volumes/Hard\ Drive\ 2/PhD\ Results/Excel\ Spreadsheets/Cell\ tracks\ -\ Transplantations/Bipolar\ phase');
But I get the following message: Warning: Name is nonexistent or not a directory: /Volumes/Hard\ Drive\ 2/PhD\ Results/Excel\ Spreadsheets/Cell\ tracks\ -\ Transplantations/Bipolar\ phase. > In path at 110 In addpath at 87
Similarly, if I enter: [type,sheetname] = xlsfinfo('/Volumes/Hard\ Drive\ 2/PhD\ Results/Excel\ Spreadsheets/Cell\ tracks\ -\ Transplantations/Bipolar\ phase/Cell\ tracks\ summary\ -\ micrometres.xlsx')
I get the error message: Error using validpath>getFullName (line 74) File '/Volumes/Hard\ Drive\ 2/PhD\ Results/Excel\ Spreadsheets/Cell\ tracks\ -\ Transplantations/Bipolar\ phase/Cell\ tracks\ summary\ -\ micrometres.xlsx' not found.
Error in validpath (line 29) filenameOut = getFullName(filename);
Error in xlsfinfo (line 45) filename = validpath(filename);
Would anyone know of an easy way to add the folder to the search path, so that I don't have to go into the folder manually every time I want to import data from that folder?
Thank you.
Best Renee
  댓글 수: 1
Renee
Renee 2013년 11월 9일
Thank you for your reply.
However, I don't think it is the answer I am looking for.
I know that xlsread and xlsfinfo works fine if I keep the Excel file in the MATLAB folder (which is the Current Folder when I launch Matlab) or if I manually go to the folder the Excel file is located in and add that folder to my search path. However, for organisational reasons I'd rather keep my Excel file on a different hard drive, in a different folder. I was wondering if there was a way for Matlab to import data from my Excel file without me having to manually go to the folder and add it to my search path.
Sorry if my initial question was not clear. Hope this clarifies it better.

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

채택된 답변

Jan
Jan 2013년 11월 10일
Try to insert the spaces without the escape characters:
addpath(['/Volumes/Hard Drive 2/PhD Results/Excel Spreadsheets/Cell tracks - ', ...
'Transplantations/Bipolar phase']);
But adding a folder to the path only to read a file from there is not efficient. Better use the absolute path of the file for the import.
  댓글 수: 1
Renee
Renee 2013년 11월 10일
Dear Jan,
Thank you. Once I take out the escape characters both using addpath to add the folder and importing using the absolute path of the file works.
Best Renee

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

추가 답변 (1개)

vaishali
vaishali 2013년 11월 8일
Keep the file in current folder, don't use add 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