Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Can someone explain the how to input and shift a vector using GUI in matlab? Tha

ID: 3731649 • Letter: C

Question

Can someone explain the how to input and shift a vector using GUI in matlab? Thanks.

Project 3

Project Assignment

Design a general analysis system using Matlab’s Graphical User Interface Design Environment (GUIDE) that completes the

following analysis types:

1. Addition of two sinusoids.

2. Product of two sinusoids

3. Shifted product of a user supplied data vector

4. Linear system of equations analysis.

Sine Wave Analyses

Analysis types 1 and 2 are similar in description and thus will be described concurrently. These analysis types requires the

user to input the amplitude, frequency, and phase offset of 2 distinct sine waves. The amplitude and frequency for each sine

wave is obtained separately from the user through the appropriate input dialog boxes. The phase offset for each sine wave

is obtained from the respective slider for each sine wave. The slider limits should enable the addition of a phase offest value

between

2

and

2

.

These analyses also requires user input values for the sample frequency and length of the samples. Use these values to

determine the length of each sine wave. Plot Input Sinewave 1 in plot area 1 and Input Sinewave 2 in plot area 2 for both

analysis types 1 and 2. Plot area 3 contains the sum of Input Sinewaves 1 and 2 along with a plot of the function handle

specified by the user in Input Area 3. Similarly, plot area 3 contains the product of Input Sinewaves 1 and 2 along with a

plot of the function handle specified by the user in Input Area 3..

User Supplied Data Analysis

The third analysis type consists of operations on a user supplied data vector. This section displays the data vector in plot

area 1, a shifted version of the input in plot area 2, and the product of the shifted and unshifted version of the data vector

in plot area 3. The user should be able to shift the input data to the left or to the right by an amount equal to the length of

user supplied data vector.

Linear System of Equations Analysis

Finally, the analysis system should provide the solution to a linear system of equation. The name of the coefficient matrix

and the output vector should be provided by the user. The analysis system will use those values to calculate and display

the solution to the system of equations.

1

Analysis Type Selection

The type of analysis is determined by a pop-up menu with a list of the 4 analysis types.

Display Results Button

Input Sine 1 Project 3 GUI Amp Frea Phase Offset 0.8 0.6 0.4 0.2 0 Input Sine 2 Amp Frea Phase Offset Input Area 3 Edit Text 0 0.5 Sample Freq Sample Length(s) 10 User Supplied Data Section Input Data File Name Data Shift Slider 0.8 0.6 0.4 0.2 0 Edit Text Linear Svstem of Output Vector Edit Text Coefficient Matrix Edit Text Solution Vector 0.5 Edit Text Analysis Selector Add Display Result 0.5 0 0 0.2 0.4 0.6 0.8 Figure 1: Example Project 3 Analysis System

Explanation / Answer

Callback Function: The function that controls component behavior by performing some action in response to an event for that component is called a callback function.

Callback function in GUI: Software that works as an interface between a computer and its user and which has graphic elements(Dialog box,icons,menus, scroll bars) is called as GUI(Graphical user interface).

NOTE: callback execution might be delayed if the call back involves CPU intensive task or if MATLAB software processing another task.

Some kinds of callback functions:

Example: Plot button Callback

The plot button callback performs 3 tasks: 1.Gets the name of the variables selected by the user in listbox. 2. Type of the plot selected by the use in the pop up menu. 3. Constructs and evaluates the plotting command in the MATLAB base workspace.   

Callback Property Description Components ButtonDownFcn Executes when the user presses a mouse button while the pointer is on or within five pixels of a component. Axes,
figure, uibuttongroup, uicontrol, uipanel
Callback Control action. Executes, for example, when a user clicks a push button or selects a menu item. Uicontextmenu, uicontrol, uimenu ClickedCallback Control action. Executes when the push tool or toggle tool is clicked. For the toggle tool, this is independent of its state. Uipushtool, uitoggletool CloseRequestFcn Executes when the figure closes. Figure CreateFcn Initializes the component when it is created. It executes after the component is created, but before it is displayed. Axes,
figure, uibuttongroup, uicontextmenu, uicontrol, uimenu, uipanel, uipushtool, uitoggletool, uitoolbar
DeleteFcn Performs cleanup operations just before the component is destroyed. Axes,
figure, uibuttongroup, uicontextmenu, uicontrol, uimenu, uipanel, uipushtool, uitoggletool, uitoolbar
KeyPressFcn Executes when the user presses a keyboard key and the callback's component has focus. Uicontrol, figure OffCallback Control action. Executes when the state of a toggle tool is changed to off. Uitoggletool OnCallback Control action. Executes when the state of a toggle tool is changed to on. Uitoggletool ResizeFcn Executes when a user resizes a panel or button group whose Resize behavior is set to Other. Figure, uibuttongroup, uipanel SelectionChangeFcn Executes when a user selects a different radio button or toggle button in a button group component. Uibuttongroup WindowButtonDownFcn Executes when you press a mouse button while the pointer is in the figure window. Figure WindowButtonMotionFcn Executes when you move the pointer within the figure window. Figure WindowButtonUpFcn Executes when you release a mouse button. Figure