現在この質問をフォロー中です
- フォローしているコンテンツ フィードに更新が表示されます。
- コミュニケーション基本設定に応じて電子メールを受け取ることができます。
import data into matlab
1 回表示 (過去 30 日間)
古いコメントを表示
I have imported data into uitable in gui, but data are large and appear statement: Matlab is not responding.
Is uitable appropriate for importing large files?
採用された回答
Walter Roberson
2015 年 10 月 7 日
編集済み: Walter Roberson
2015 年 10 月 7 日
uitable() does not import data. uitable is for creating table structures in graphics.
There is a table() data type which has various import routines including readtable: is that the routine you are using? What kind of file are you importing the data from?
18 件のコメント
Radoslav Vandzura
2015 年 10 月 7 日
編集済み: Radoslav Vandzura
2015 年 10 月 7 日
I import .xls or .xlsx file. I have file with about 180 000 rows. After pressing push button in gui, data shoult be displayed in uitable...After that I want to analyze data.
Part of my code is: global strFilename
[num,txt,raw] = xlsread(strFilename)
set(handles.edit3, 'data', raw); -edit3 is tag of uitable in gui
Walter Roberson
2015 年 10 月 7 日
If you are using GUIDE then handles.edit3 would be the tag of a uicontrol('style','edit') rather than a uitable.
I just experimented with a uitable with 180000 rows and 1023 columns. Creating the uitable took only a fraction of a second; modifying it with new data was even faster, including the time to format the numbers into strings. It was faster than I could mentally measure.
The only notable delay I had in any of this, in the graphics part, was creating the initial figure. Creating the data with rand() was slower than any of the display.
Reading 180000 rows with xlsread() certainly could take time. You could put a tic/toc around the xlsread to get an idea of how long it takes.
Radoslav Vandzura
2015 年 10 月 9 日
And how can I set tag of uicontrol('style','edit')?....uitable I insert as an object uitable in guide....
Walter Roberson
2015 年 10 月 9 日
table_h = findobj(ancestor(hObject, 'figure'), 'type', 'uitable');
set(table_h, 'data', raw);
Unless you have more than one uitable.
Radoslav Vandzura
2015 年 10 月 9 日
編集済み: Radoslav Vandzura
2015 年 10 月 9 日
And If I load data only into 1 uitable? I dont know what you mean more than 1 uitable....
Walter Roberson
2015 年 10 月 9 日
My suggested code is fine as long as you only have 1 uitable. The code would have problems if you had 2 or more uitable.
Radoslav Vandzura
2015 年 10 月 9 日
編集済み: Radoslav Vandzura
2015 年 10 月 9 日
I already tried your suggested code but it doesnt work so good:( Somewhere is value NaN and there are not loaded all data of file. If I tried tic toc, result is t =168.4031....It takes very long time .....How can I do it faster? ....and when i want to use these data later..in data mining (data analyze)...how shoult I do it?....What do you think about datastore? ....Shout I try it?....Thank you very much for your answer....I appreciate your help...:)
Radoslav Vandzura
2015 年 10 月 10 日
編集済み: Walter Roberson
2015 年 10 月 10 日
My code is:
function pushbutton1_Callback(hObject, eventdata, handles)
set(handles.text2,'String','');
global strFilename
% ask user which file to import - road to file
FilterSet = {'*.xl??','Excel Files (*.xl?)';...
'*.csv','CSV Files (*.csv)';...
'*.*','All Files (.)'};
[FileName,PathName] = ...
uigetfile(FilterSet,'Select Excel file to import');
if ~isequal(FileName,0)
strFilename = fullfile(PathName,FileName);
set(handles.text2,'String',strFilename)
else
set(handles.text2,'String','Incorrect loading!!!')
end
function pushbutton2_Callback(hObject, eventdata, handles)
global strFilename
tic;
[num,txt,raw] = xlsread(strFilename)
t=toc
table_h = findobj(ancestor(hObject, 'figure'), 'type', 'uitable');
set(table_h, 'data', raw);
Walter Roberson
2015 年 10 月 10 日
You are measuring the speed of the xlsread(), not the speed of sending the data to the uitable.
You might be able to get faster xlsread() using http://www.mathworks.com/matlabcentral/fileexchange/22365-function-for-faster-data-transfer-matlab-%3C-%3E-excel
Radoslav Vandzura
2015 年 10 月 11 日
And if i want to get faster sending the data to the uitable, should i use the same way?
Walter Roberson
2015 年 10 月 11 日
My tests indicate that once you have the data read in, then creating the uitable() is under 0.03 seconds.
The file exchange contribution linked to above is only for reading the data in possibly faster. It has nothing to do with uitable() . uitable is a graphics feature entirely unrelated to any particular method of getting data from a file.
Radoslav Vandzura
2015 年 10 月 12 日
編集済み: Radoslav Vandzura
2015 年 10 月 12 日
According link above I don´t know to do it :( Is there any method how to use it, any steps? How I insert this file xlsread1.m into my code? Should I use all the code?...
Walter Roberson
2015 年 10 月 12 日
Download the .zip file. Unzip it in to a new directory. Use pathtool to add the directory to your MATLAB path. Then in your code, where you currently have xlsread() put in
Excel = actxserver ('Excel.Application');
File = strFilename;
if ~exist(File, 'file')
Excel.Quit
Excel.delete
clear Excel
error('file does not exist: %s', File);
end
Excel.Workbooks.Open(File);
assignin('base', 'Excel', Excel);
[num, txt, raw] = xlsread1(strFilename);
Excel.ActiveWorkbook.Save;
Excel.Quit
Excel.delete
clear Excel
If you are reading multiple files then some of this does not need to be repeated each time.
Note: I seldom run MS Windows (it frustrates me immensely), so this is not tested.
Radoslav Vandzura
2015 年 10 月 13 日
It is going good, I am so thankful, thank you very much for your help....;-)
Radoslav Vandzura
2015 年 11 月 8 日
And what is code of this?
I wrote this:
function pushbutton4_Callback(hObject, eventdata, handles)
waitfor(gcf)
x=0.5;
waitbar(x+0.3,h,'Data are saving')
pause(3)
get(handles.edit3,'data')%edit3 is tag for uitable object in guide
x=0.8;
waitbar(x+0.2,h,'Data are succesfully saved')
pause(2)
close(h)
But it doesnt work.
その他の回答 (0 件)
参考
カテゴリ
Help Center および File Exchange で Migrate GUIDE Apps についてさらに検索
タグ
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!エラーが発生しました
ページに変更が加えられたため、アクションを完了できません。ページを再度読み込み、更新された状態を確認してください。
Web サイトの選択
Web サイトを選択すると、翻訳されたコンテンツにアクセスし、地域のイベントやサービスを確認できます。現在の位置情報に基づき、次のサイトの選択を推奨します:
また、以下のリストから Web サイトを選択することもできます。
最適なサイトパフォーマンスの取得方法
中国のサイト (中国語または英語) を選択することで、最適なサイトパフォーマンスが得られます。その他の国の MathWorks のサイトは、お客様の地域からのアクセスが最適化されていません。
南北アメリカ
- América Latina (Español)
- Canada (English)
- United States (English)
ヨーロッパ
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
アジア太平洋地域
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)