Reading microsoft excel spreadsheets not within the 'Current Folder' directory in Matlab working environment?

조회 수: 35 (최근 30일)
I am familiar with the xlsread functions, however I understand the file must be within the current path/folder that matlab is working in. Is it possible to load spreadsheet data from a random location on the drive using the load command? I have come accross the uigetfile function which is useful since I have just started working with GUIs (GUIDE etc):
[filename1, pathname1, FilterIndex] = uigetfile;
When I load the data would it matter to us the path or filename?
Thanks for any advice, Al

답변 (1개)

Srinivas
Srinivas 2013년 4월 4일
you can give your full path in xlsread some thing like this
data = xlsread('C:\Users\username\myfile.xlsx')
  댓글 수: 2
Jordan Andersen
Jordan Andersen 2017년 1월 20일
편집: Jordan Andersen 2017년 1월 20일
Be sure there are no spaces in your file path as MATLAB recognises the space character as a break in a command. It's a good habit to always use an underscore instead of a space when naming data files from the start.
e.g. data = xlsread('C:\Users\username\my_file.xlsx') instead of ('C:\...\my file.xlsx')
Walter Roberson
Walter Roberson 2017년 1월 20일
편집: Walter Roberson 2017년 1월 20일
Spaces within quoted strings do not terminate commands (except indirectly; you have to be careful if you use dos() or system() or unix() )
Historically, though, some Simulink related toolboxes had problems with directories that had spaces or special characters in the name.

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

카테고리

Help CenterFile Exchange에서 Environment and Settings에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by