Lompat ke konten Lompat ke sidebar Lompat ke footer

Export Import Excell Menggunakan Matlab

dasar untuk mengekspor / impor excel  menggunakan  Matlab menggunakan perintah:
xlsread
xlswrite




EKSPORT EXCEL

function btnProses_Callback(hObject, eventdata, handles)
b1=get(handles.edBaris,'String');
b2=get(handles.edKolom,'String');
in1=str2num(b1);%double(b1)
in2=str2num(b2);%double(b1)
baris=in1;
kolom=in2;
y=randi(baris,kolom);

header= linspace(1,kolom,kolom);
row = linspace(1,baris,baris);
set(handles.myTablelp2mAray,'data',y,'ColumnName',header,'RowName',row);
set(handles.myTablelp2mAray,'Userdata',y);


% --- Executes on button press in btnExport.
function btnExport_Callback(hObject, eventdata, handles)
dt1=get(handles.myTable1,'Userdata');
filename = 'testdataex1.xls';
xlswrite(filename,dt1,1,'A1')
        myicon(:,:,1) = [0 1; 0 1];
        myicon(:,:,2) = [.8 1; 0 .3];
        myicon(:,:,3) = [.3 0; .9 .5];
        h=msgbox('Sukses Exsport','Success','custom',myicon);




IMPORT EXCEL

% --- Executes on button press in btnBrowse.
function btnBrowse_Callback(hObject, eventdata, handles)
[namafile,direktori]=uigetfile({'*.xls;*.xls','file excel(*.xls,*.xls)';'*.*','semua file(*.*)'},'buka file excell');

alamatfile=fullfile(direktori,namafile);
set(handles.edit1,'String',alamatfile);

[a,b,c]=xlsread(alamatfile);
%     'NO'    'NAMA'    'USIA'    'BERAT'    'TINGGI'
%     [ 1]    'ADAM'    [  12]    [   30]    [   150]
%     [ 2]    'SUSI'    [  15]    [   35]    [   155]
%     [ 3]    'DEDI'    [  17]    [   40]    [   145]
%     [ 4]    'DONI'    [  15]    [   38]    [   156]

bar=size(c,1);
col=size(c,2);

judul=c(1,2:col);
data=c(2:bar,2:col);
nom=linspace(1,bar-1,bar-1);
set(handles.myTable2lp2mAray,'data',data,'ColumnName',judul,'RowName',nom);
set(handles.myTable2lp2mAray,'Userdata',data);

        myicon(:,:,1) = [0 1; 0 1];
        myicon(:,:,2) = [.8 1; 0 .3];
        myicon(:,:,3) = [.3 0; .9 .5];
        h=msgbox('Sukses import','Success','custom',myicon);

Posting Komentar untuk "Export Import Excell Menggunakan Matlab"