Sie sind auf Seite 1von 25

ELECTRONICS AND INSTRUMENTATION

BE II YEAR
2017-2018
SOFTWARE WORKSHOP
EI-27992
DATA EXPORTING TO EXCEL

1
ACKNOWLEDGEMENT

It has been great honour and privilege to undergo this initiative of report
writing. We are very much thankful to our teachers, parents, seniors and
friends for providing all facilities and support to meet our project
requirements.
We would like to take opportunity to express our humble gratitude.
Their constant guidance and willingness to share their vast knowledge
made us understand this undertaking and its manifestations in great
depths and helped us to complete the assignment task.
Although there may be many who remain unacknowledged in this
humble note of gratitude there are none who remain unappreciated.

2
PREFACE
It gives us immense pleasure in presenting a report on “DATA
EXPORTING USING MATLAB”. Through the preparation of this
report, we have endeavoured to highlight the functionality of MATLAB.
Through this report we have emphasized the ideas and functionality on
the MATLAB and GUI.

Our study also focuses on the GUI and exporting data from MATLAB to
EXCELL sheet.

We hope this will serve as an asset to concerned authorities.

3
COPYRIGHT NOTICE

ALL RIGHTS RESERVED. This technical report contains protected


material. Any unauthorized reprint or use of this material is prohibited.
No part of this report may be reproduced or transmitted in any form or
by any means ,electronic or mechanical , photocopying ,recording or by
any information storage and retrieval system without express written
permission from the author/publisher .In case of any violation all legal
jurisdictions will be liable.

4
LETTER OF TRANSMITTAL

To
The Director
SGSITS Indore
Date: 7th April 2018
Ref no. : SGSITS/15/2018
Dear Sir,
Subject: Letter of transmittal on “Matlab report”.

This report is written with reference to your letter no. SGSITS/15/2018


in which you have asked us to study “Data exporting using Matlab”. We
have endeavoured over the topic and would like to present our findings.
We hope that this report will give you an insight into the topic and
welcome recommendations concerning the same.

Thanking You
YOURS SINCERELY
All the group members.

5
INDEX
S.No. Title Page
no.
1 Cover page i
2 Title page ii

3 Acknowledgement iii

4 Preface iv

5 Copyright Notice v
6 Letter of transmittal vi

7 Table of Content vii

8 List of illustration viii

9 Abstract 7

10 Introduction 8
11 Code 14

12 Working 21
13 Uses 22

14 Future Aspects 23
15 Advantages and Disadvantages 24

16 Reference 25

6
Absatract

This is a MATLAB GUI (Graphical User Interface) based project that


exports the data to Microsoft Excel. Basically it is a kind of registration
form in which we take information from user in the specified edit boxes
and that data is transferred to MS Excel. In this report we have given
brief description on MATLAB and GUI. We have also printed the code
that we made for this project and have attached screenshots of the form
too. This report not only tells about the uses and advantages –
disadvantages of this project but also consists of future aspects that can
be achieved later.

7
INTRODUCTION

What Is MATLAB?

MATLAB is a high-performance language for technical computing. It


integrates computation, visualization, and programming in an easy-to-
use environment where problems and solutions are expressed in familiar
mathematical notation. Typical uses include:

 Math and computation


 Algorithm development
 Modelling, simulation, and prototyping
 Data analysis, exploration, and visualization
 Scientific and engineering graphics
 Application development, including Graphical User Interface
building

MATLAB is an interactive system whose basic data element is an array


that does not require dimensioning. This allows you to solve many
technical computing problems, especially those with matrix and vector
formulations, in a fraction of the time it would take to write a program in
a scalar non interactive language such as C or FORTRAN.
The name MATLAB stands for matrix laboratory. MATLAB was
originally written to provide easy access to matrix software developed
by the LINPACK and EISPACK projects, which together represent the
state-of-the-art in software for matrix computation.
MATLAB has evolved over a period of years with input from many
users. In university environments, it is the standard instructional tool for
introductory and advanced courses in mathematics, engineering, and
science. In industry, MATLAB is the tool of choice for high-
productivity research, development, and analysis.
MATLAB features a family of application-specific solutions called
toolboxes. Very important to most users of MATLAB, toolboxes allow
8
you to learn and apply specialized technology. Toolboxes are
comprehensive collections of MATLAB functions (M-files) that extend
the MATLAB environment to solve particular classes of problems.
Areas in which toolboxes are available include signal processing, control
systems, neural networks, fuzzy logic, wavelets, simulation, and many
others.
Although MATLAB is intended primarily for numerical computing, an
optional toolbox uses the MuPAD symbolic engine, allowing access
to symbolic computing abilities. An additional package, Simulink, adds
graphical multi-domain simulation and model-based
design for dynamic and embedded systems.
As of 2017, MATLAB has roughly 1 million users across industry and
academia. MATLAB users come from various backgrounds
of engineering, science, and economics.

Graphical User Interface


The graphical user is a type of user interface that
allows users to interact with electronic devices through
graphical icons and visual indicators such as secondary notation, instead
of text-based user interfaces, typed command labels or text navigation.
GUIs were introduced in reaction to the perceived steep learning
curve of command-line interfaces (CLIs), which require commands to be
typed on a computer keyboard.
The actions in a GUI are usually performed through direct
manipulation of the graphical elements. Beyond computers, GUIs are
used in many handheld mobile devices such as MP3 players, portable
media players, gaming devices, smartphones and smaller household,
office and industrial controls. The term GUI tends not to be applied to
other lower-display resolution types of interfaces, such as video
games(where head-up display (HUD) is preferred), or not including flat
screens, like volumetric displays because the term is restricted to the
9
scope of two-dimensional display screens able to describe generic
information, in the tradition of the computer science research at the
Xerox Palo Alto Research Centre.
A GUI uses a combination of technologies and devices to provide a
platform those users can interact with, for the tasks of gathering and
producing information.
A series of elements conforming a visual language have evolved to
represent information stored in computers. This makes it easier for
people with few computer skills to work with and use computer
software. The most common combination of such elements in GUIs is
the windows, icons, menus, pointer (WIMP) paradigm, especially
in personal computers.
The WIMP style of interaction uses a virtual input device to represent
the position of a pointing device, most often a mouse, and presents
information organized in windows and represented with icons. Available
commands are compiled together in menus, and actions are performed
making gestures with the pointing device. A window manager facilitates
the interactions between windows, applications, and the windowing
system. The windowing system handles hardware devices such as
pointing devices, graphics hardware, and positioning of the pointer.
In personal computers, all these elements are modeled through a desktop
metaphor to produce a simulation called a desktop environment in which
the display represents a desktop, on which documents and folders of
documents can be placed. Window managers and other software
combine to simulate the desktop environment with varying degrees of
realism.

10
SCREENSHOTS

11
12
13
CODE

function varargout = regform(varargin)


% REGFORM MATLAB code for regform.fig
% REGFORM, by itself, creates a new REGFORM or raises the
existing
% singleton*.
%
% H = REGFORM returns the handle to a new REGFORM or the handle
to
% the existing singleton*.
%
% REGFORM('CALLBACK',hObject,eventData,handles,...) calls the
local
% function named CALLBACK in REGFORM.M with the given input
arguments.
%
% REGFORM('Property','Value',...) creates a new REGFORM or raises
the
% existing singleton*. Starting from the left, property value
pairs are
% applied to the GUI before regform_OpeningFcn gets called. An
% unrecognized property name or invalid value makes property
application
% stop. All inputs are passed to regform_OpeningFcn via
varargin.
%
% *See GUI Options on GUIDE's Tools menu. Choose "GUI allows
only one
% instance to run (singleton)".
%
% See also: GUIDE, GUIDATA, GUIHANDLES

% Edit the above text to modify the response to help regform

% Last Modified by GUIDE v2.5 24-Mar-2018 22:24:48

% Begin initialization code - DO NOT EDIT


gui_Singleton = 1;
gui_State = struct('gui_Name', mfilename, ...
'gui_Singleton', gui_Singleton, ...
'gui_OpeningFcn', @regform_OpeningFcn, ...
'gui_OutputFcn', @regform_OutputFcn, ...
'gui_LayoutFcn', [] , ...
'gui_Callback', []);
if nargin && ischar(varargin{1})
gui_State.gui_Callback = str2func(varargin{1});
end

14
if nargout
[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:});
else
gui_mainfcn(gui_State, varargin{:});
end
% End initialization code - DO NOT EDIT

% --- Executes just before regform is made visible.


function regform_OpeningFcn(hObject, eventdata, handles, varargin)
% This function has no output args, see OutputFcn.
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% varargin command line arguments to regform (see VARARGIN)

% Choose default command line output for regform


handles.output = hObject;
d= date;
set(handles.text24,'string',d);
f= fix(clock);
e= strcat(num2str(f(1,4)),':',num2str(f(1,5)),':',num2str(f(1,6)));
set(handles.text25,'string',e);
guidata(hObject, handles);% Update handles structure

% UIWAIT makes regform wait for user response (see UIRESUME)


% uiwait(handles.figure1);

% --- Outputs from this function are returned to the command line.
function varargout = regform_OutputFcn(hObject, eventdata, handles)
% varargout cell array for returning output args (see VARARGOUT);
% hObject handle to figure
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Get default command line output from handles structure


varargout{1} = handles.output;

function edit1_Callback(hObject, eventdata, handles)


% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit1 as text


% str2double(get(hObject,'String')) returns contents of edit1
as a double
a= get(handles.edit1,'string');

15
% --- Executes during object creation, after setting all properties.
function edit1_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit2_Callback(hObject, eventdata, handles)


% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit2 as text


% str2double(get(hObject,'String')) returns contents of edit2
as a double
b= get(handles.edit2,'string');

% --- Executes during object creation, after setting all properties.


function edit2_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit2 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit3_Callback(hObject, eventdata, handles)


% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit3 as text


% str2double(get(hObject,'String')) returns contents of edit3
as a double

16
c= get(handles.edit3,'string');

% --- Executes during object creation, after setting all properties.


function edit3_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit3 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit4_Callback(hObject, eventdata, handles)


% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit4 as text


% str2double(get(hObject,'String')) returns contents of edit4
as a double
d= get(handles.edit4,'string');

% --- Executes during object creation, after setting all properties.


function edit4_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit4 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit7_Callback(hObject, eventdata, handles)


% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit7 as text

17
% str2double(get(hObject,'String')) returns contents of edit7
as a double
e= get(handles.edit7,'string');

% --- Executes during object creation, after setting all properties.


function edit7_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit7 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

% --- Executes on button press in pushbutton1.


function pushbutton1_Callback(hObject, eventdata, handles)
% hObject handle to pushbutton1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
filename='regform1.xlsx'
k= fix(clock)
fileexist= exist(filename,'file')
if fileexist== 0
header={'Name','Email id','Contact no.','Enrollment
no.','College','City','Gender','Branch','Date','Time'}
xlswrite(filename,header)
else
a= get(handles.edit1,'string');
b= get(handles.edit2,'string');
c= get(handles.edit3,'string');
d= get(handles.edit4,'string');
e= get(handles.edit7,'string');
f= get(handles.edit8,'string');
g= get(handles.edit9,'string');
h= get(handles.edit10,'string');
i= date
j=strcat(num2str(k(1,4)),':',num2str(k(1,5)),':',num2str(k(1,6)))
[~,~,input]= xlsread(filename);
Data={a,b,c,d,e,f,g,h,i,j};
output= cat(1,input,Data)
xlswrite(filename,output)
end
set(handles.edit1,'string','');
set(handles.edit2,'string','');
set(handles.edit3,'string','');
set(handles.edit4,'string','');
set(handles.edit7,'string','');

18
set(handles.edit8,'string','');
set(handles.edit9,'string','');
set(handles.edit10,'string','');
msgbox('Saved!!');

function edit8_Callback(hObject, eventdata, handles)


% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit8 as text


% str2double(get(hObject,'String')) returns contents of edit8
as a double
f= get(handles.edit8,'string');

% --- Executes during object creation, after setting all properties.


function edit8_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit8 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit9_Callback(hObject, eventdata, handles)


% hObject handle to edit9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit9 as text


% str2double(get(hObject,'String')) returns contents of edit9
as a double
g= get(handles.edit9,'string');

% --- Executes during object creation, after setting all properties.


function edit9_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit9 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

19
% Hint: edit controls usually have a white background on Windows.
% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

function edit10_Callback(hObject, eventdata, handles)


% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)

% Hints: get(hObject,'String') returns contents of edit10 as text


% str2double(get(hObject,'String')) returns contents of edit10
as a double
h= get(handles.edit10,'string');

% --- Executes during object creation, after setting all properties.


function edit10_CreateFcn(hObject, eventdata, handles)
% hObject handle to edit10 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles empty - handles not created until after all CreateFcns
called

% Hint: edit controls usually have a white background on Windows.


% See ISPC and COMPUTER.
if ispc && isequal(get(hObject,'BackgroundColor'),
get(0,'defaultUicontrolBackgroundColor'))
set(hObject,'BackgroundColor','white');
end

20
WORKING
The project is GUI (Graphical User Interface) based . The basic work of
the Registration Form is to export the data entered in the form to the
excel sheet. In the opening function of GUI we have ‘date’ fuction
which gives the current date and ‘fix(clock)’ function which gives both
current date and time in the form of row matrix from which we have
extracted time components and concatenated them using ‘strcat’
function . The sole purpose of writing these function in opening function
is to display the date and time as soon as the form is opened.

In the callback functions of the edit boxes we have used


‘get(handles.edit1,'string')’ function which is used to input the data in
the edit box of the GUI. Here handles is a structure and edit1 is the tag
of the edit text box and ‘string’ shows that string is to be entered. Similar
code is for rest of the objects only the tag will change.

In the callback function of pushbutton ‘exist(filename,'file')’ function is


used which checks whether the file exists or not , where filename is the
predefined name of file. If file do not exists than it is created using
‘xlswrite’ function and if file exist than it is first read using ‘xlsread’
function and data is stored in some variable viz. Data than all the inputs
are concatenated using ‘cat’ function and stored in another variable viz.
output and after that it is written in in excel using ‘xlswrite’ . In the
‘msgbox’ function the message is written that is to be displayed after
pushbutton is pressed.

As the pushbutton is pressed the data from registration form is


transferred to the excel sheet.

21
Uses

This form has multiple uses in collecting data from a number of sources
and at the same time this data can be made available in excel sheet.
Following
are the uses of this from:
1. To get data directly from people and store it in excel sheet.
2. To use as a registration form.
3. Getting submission time of form from the Matlab itself.
4. Can be used to register data of participants for an event.
5. It can be used as admission or application form.

22
Future Aspects

 This form can be modified to send the data to the 3rd party using E-mail.
 In case of registration form, an registration no. can be sent to user as
soon as he/she fills the form.

23
Advantages and Disadvantages

Advantages
 It can be customised as per the requirement of entries in the form.
 It simplifies the data entry process as compared to direct data entry
in Excel.

Disadvantages
 It can’t be used for online data sending through windows 8 and 10.
 It cannot edit the data that has already been input.

24
References

 www.mathworks.com
 www.google.com
 www.wikipedia.com

25

Das könnte Ihnen auch gefallen