browse for an excel file and save the data as a matrix

조회 수: 5 (최근 30일)
Matthew
Matthew 2012년 3월 15일
I want to create a function to browse for an excel file and save the data as a matrix. I have only been able to find ways to import data when I already know the name of the file. I used the funtcion generator to create a funtion to do it but it doesn't include code to save the matrix. I would think you could do something like this: datafile1 = uiimport('-file'); xlsread(datafile) but that doesn't work. I'm sure this is a simple task but I can't find any forums or demos that explain hot to do this. The excel file I will use will have two columns one with date and time and the other with a number value and there are no headers in the file. I want to be able to select a different file everytime and have it save as a matrix.

채택된 답변

Geoff
Geoff 2012년 3월 15일
Use the function uigetfile to browse for a filename, then pass that name to xlsread.

추가 답변 (2개)

Matthew
Matthew 2012년 3월 15일
I tried this but it only returned the data from the second column and did not do the date and time conversion
datafile1 = uigetfile; xlsread(datafile1,'Sheet1','','',@convertSpreadsheetDates);

Matthew
Matthew 2012년 3월 15일
I got it figured out thanks

카테고리

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

Community Treasure Hunt

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

Start Hunting!

Translated by