Importing Data from Excel File 'Faster' ??

Actually I'm working now on a GUI it's supposed that i have data (Matrix 2D of strings) like that :
A={'hello' 'world' 'hi';'my' 'name' is'};
it's simple,but I've put it in excel file and in the GUI m-file I've made a callback function that import that data from that file and save to a matrix and do some for loops to search for something inside this data . and finally saving the matrix back into the file .
THAT'S ACTUALLY CONSUMING TIME AND MY PROGRAM IS SLOW
Is there is a way to make it faster ? , Or any other solution ?
Thanks in Advance !

5 件のコメント

Seth DeLand
Seth DeLand 2011 年 3 月 2 日
Hi Mohamed,
Do you know what's taking up the most time in your callback (importing the data, or looping through the matrix)? You could run the profiler on your code to investigate.
Mohamed Alaa
Mohamed Alaa 2011 年 3 月 3 日
both .. but there is nothing i could do about the searching operation [ the loops ] .
Oleg Komarov
Oleg Komarov 2011 年 3 月 3 日
Nothing you could do about the searching and yet you're using loops is already contradiction. You can post the loops with example input and we can try to make it faster other than optimizing the I/O operations.
Mohamed Alaa
Mohamed Alaa 2011 年 3 月 3 日
G=importdata('mydata.xls');
dvd=G.Sheet1;
f=size(dvd);
no_rows=f(1);
k=1;
%this is the simple part that searches but i do another operations before that to avoid spaces ,dots problems
search_object=get(handles.edit10,'string');
for i=1:no_rows
for j=1:6
f=regexp(dvd{i,j},New_search_object,'ignorecase','match');
R=isempty(f);
if R~=1
B{w}=sprintf('%d - %s',i,dvd{i,j});
w=w+1;
end
end
end
Oleg Komarov
Oleg Komarov 2011 年 3 月 3 日
I would:
- try to eliminate _importdata_
- definitely concentrate on the loops: no preallocation and regexp can also operate on cell arrays.
Try to post another thread with a meaningful example of the type of excel you usually have and more code.

サインインしてコメントする。

 採用された回答

Oleg Komarov
Oleg Komarov 2011 年 3 月 2 日

0 投票

You can make it faster by using a modified version of xlsread modified version of xlsread
Oleg

2 件のコメント

Matt Tearle
Matt Tearle 2011 年 3 月 2 日
Also note that xlsread/write are editable MATLAB code... meaning you can open them up, see how they work and copy bits and pieces. Hence, you can strip them down to the barest basics you need.
Mohamed Alaa
Mohamed Alaa 2011 年 3 月 3 日
ok Thank you . I'll try that .

サインインしてコメントする。

その他の回答 (0 件)

Community Treasure Hunt

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

Start Hunting!

Translated by