Advanced Microprocessor Questions
Advanced Microprocessor Questions
In Command Window:
>> [1 2 3 4]
ans =
1 2 3 4
>> [1;2;3;4]
ans =
1
2
3
4
>> [4 5 ; 6 7]
ans =
4 5
6 7
>> [1 2 3 ; 4 5 6 ; 7 8 9]
ans =
1 2 3
4 5 6
7 8 9
Multiplication: A*B
Division: A/B
Addition: A+B
Subtraction: A-B
Transpose : trans(A)
Inverse of matrix: inv(A)
>> num=10
num =
10
>> den=[1 7 10 9]
den =
1 7 10 9
>> sys=tf(num,den)
Transfer function:
10
----------------------
s^3 + 7 s^2 + 10 s + 9
>> pzmap(sys)
Pole-Zero Map
1.5
0.5
Imaginary Axis
-0.5
-1
-1.5
-6 -5 -4 Real -3
Axis -2 -1 0
>> step(sys)
Step Response
1.4
1.2
0.8
Amplitude
0.6
0.4
0.2
0
0 1 2 3 4 5 6 7
Time (sec)
Impulse Response
0.7
0.6
0.5
0.4
Amplitude
0.3
0.2
0.1
-0.1
0 1 2 3 4 5 6 7 8
Time (sec)
Determine the TF of a given impulse response
g(t)=e^-t (1-cos2t)
>> f=exp(-t)*(1-cos(2*t))
f=
exp(-t)*(1-cos(2*t))
>> F=laplace(f)
F=
1/(s+1)-1/4*(s+1)/(1/4*(s+1)^2+1)
F=
dirac(x-1)-ilaplace(exp(-t)*cos(2*t),t,x)
>> rlocus(sys)
Root Locus
15
10
5
Imaginary Axis
-5
-10
-15
-16 -14 -12 -10 -8 -6 -4 -2 0 2 4
Real Axis
>> bode(sys)
Bode Diagram
50
0
Magnitude (dB)
-50
-100
-150
0
-90
Phase (deg)
-180
-270
-2 -1 0 1 2 3
10 10 10 10 10 10
Frequency (rad/sec)
To find CONTROLLABILITY and RANK of the system
>> A=[1 1;0 -1]
A=
1 1
0 -1
>> B=[1; 0]
B=
1
0
>> p=ctrb(A,B)
p=
1 1
0 0
ans =
1
CONVERSION OF TF TO STATE SPACE ANALYSIS
>> num=[1]
num =
>> den=[1 2 5 ]
den =
1 2 5
>> [A,B,C,D]=tf2ss(num,den)
A=
-2 -5
1 0
B=
1
0
C=
0 1
D=
>> [num,den]=ss2tf(A,B,C,D)
num =
0 -0.0000 1.0000
den =
1 2 5
num =
2.0000 0.5000
den =
>> sys=tf(num,den)
Transfer function:
2 s + 0.5
-----------------------
s^4 + 1.5 s^3 + 0.5 s^2
>> margin(sys)
Bode Diagram
Gm = -20.6 dB (at 0.354 rad/sec) , Pm = -36.7 deg (at 1.12 rad/sec)
100
50
Magnitude (dB) 0
-50
-100
-150
-135
-180
Phase (deg)
-225
-270
-2 -1 0 1 2
10 10 10 10 10
Frequency (rad/sec)
From the above margin plots the gain margin and phase margin directly
can be displayed as
Analyze signals
Design filters
Analyze (view) filters
Filter signals
Analyze signal spectra
You can use the Spectrum Viewer for estimating and analyzing
a signal's power spectral density (PSD). You can use the PSD
estimates to understand a signal's frequency content.
You can export SPTool signals, filters, and spectra as structures to the MATLAB
workspace or to your disk.
In each case you:
Select the items in SPTool you want to export.
Select Export from the File menu.
To save the filter filt1 you just created in this example, open the Export dialog box
with filt1 preselected:
Select filt1 in the SPTool Filters list.
Select Export from the File menu.
In addition to importing signals into SPTool, you can import filters or spectra into
SPTool from either the workspace or from a file.
The procedures are very similar to those explained in:
Step 1: Importing a Signal into SPTool for loading variables from the workspace
Loading Variables from the Disk for loading variables from your disk
Importing Spectra
When you import a power spectral density (PSD), you specify:
A variable name or a value for the PSD vector in the PSD field
A variable name or a value for the frequency vector in the Freq. Vector field
The PSD values in the PSD vector correspond to the frequencies contained in the
Freq. Vector vector; the two vectors must have the same length.
Editing Signals, Filters, or Spectra in SPTool
Selecting the names of the signals, filters, or spectra you want to edit.
Selecting the appropriate Edit menu item:
Duplicate to copy an item in an SPTool list
Clear to delete an item in an SPTool list
Name to rename an item in an SPTool list
Sampling Frequency to modify the sampling frequency associated
with either a signal (and its associated spectra) or filter in an
SPTool list
The pull-down menu next to each menu item shows the names of all selected
items.
You can also edit the following signal characteristics by right-clicking in the display
region of the Signal Browser, the Filter Visualization Tool, or the Spectrum Viewer:
Select the From Disk radio button and do either of the following:
Type the name of the file you want to import into the MAT-file Name
field and press either the Tab or the Enter key on your keyboard.
Select Browse, and then find and select the file you want to import
using the Select File to Open dialog.
Press OK to close that dialog. In either case, all variables in the MAT-file you
selected are displayed in the File Contents list.
You can now import one or more variables from the File Contents list into SPTool,
as long as these variables are scalars, vectors, or matrices.
Setting Preferences
Use Preferences from the SPTool File menu to customize displays and certain
parameters for SPTool and its four component GUIs. The new settings are saved on
disk and are used when you restart SPTool from MATLAB.
When you first select Preferences, the Preferences dialog box opens with Markers
selected by default.
You can:
Change the settings for markers from this panel of the Preferences dialog.
Choose any of the other categories listed to customize its settings.
DSP TOOLS
Analyze signals
Design filters
Analyze (view) filters
Filter signals
Analyze signal spectra
How to open DSP TOOL:-
You can use the Spectrum Viewer for estimating and analyzing
a signal's power spectral density (PSD). You can use the PSD
estimates to understand a signal's frequency content.
You can export SPTool signals, filters, and spectra as structures to the MATLAB
workspace or to your disk.
In each case you:
Select the items in SPTool you want to export.
Select Export from the File menu.
To save the filter filt1 you just created in this example, open the Export dialog box
with filt1 preselected:
Select filt1 in the SPTool Filters list.
Select Export from the File menu.
In addition to importing signals into SPTool, you can import filters or spectra into
SPTool from either the workspace or from a file.
A variable name or a value for the PSD vector in the PSD field
A variable name or a value for the frequency vector in the Freq. Vector field
The PSD values in the PSD vector correspond to the frequencies contained in the
Freq. Vector vector; the two vectors must have the same length.
Editing Signals, Filters, or Spectra in SPTool
Selecting the names of the signals, filters, or spectra you want to edit.
Selecting the appropriate Edit menu item:
Duplicate to copy an item in an SPTool list
Clear to delete an item in an SPTool list
Name to rename an item in an SPTool list
Sampling Frequency to modify the sampling frequency associated
with either a signal (and its associated spectra) or filter in an
SPTool list
The pull-down menu next to each menu item shows the names of all selected
items.
You can also edit the following signal characteristics by right-clicking in the display
region of the Signal Browser, the Filter Visualization Tool, or the Spectrum Viewer:
Select the From Disk radio button and do either of the following:
Type the name of the file you want to import into the MAT-file Name
field and press either the Tab or the Enter key on your keyboard.
Select Browse, and then find and select the file you want to import
using the Select File to Open dialog.
Press OK to close that dialog. In either case, all variables in the MAT-file you
selected are displayed in the File Contents list.
You can now import one or more variables from the File Contents list into SPTool,
as long as these variables are scalars, vectors, or matrices.
Setting Preferences
Use Preferences from the SPTool File menu to customize displays and certain
parameters for SPTool and its four component GUIs. The new settings are saved on
disk and are used when you restart SPTool from MATLAB.
When you first select Preferences, the Preferences dialog box opens with Markers
selected by default.
You can:
Change the settings for markers from this panel of the Preferences dialog.
Choose any of the other categories listed to customize its settings.
FDA TOOLS
Overview
The Filter Design and Analysis Tool (FDATool) is a powerful user interface for
designing and analyzing filters. FDATool enables you to quickly design digital FIR or
IIR filters by setting filter performance specifications, by importing filters from your
MATLAB workspace, by directly specifying filter coefficients, or by adding, moving or
deleting poles and zeros. FDATool also provides tools for analyzing filters, such as
magnitude and phase response plots and pole-zero plots. FVTool, which can be
launched from FDATool, provides a separate window for analyzing filters. You can
use FDATool as a convenient alternative to the command line filter design functions.
The tool gives you access to all of the filter design methods in the Signal Processing
Toolbox.
Analyzing the Filter
Once you've designed the filter, you can view the following filter response
characteristics in the display region or in a separate window
Magnitude response
Phase response
Magnitude and Phase responses
Group delay response
Phase delay response
Impulse response
Step response
Pole-zero plot
Zero-phase response--available from the y-axis context menu in a Magnitude
or Magnitude and Phase response plot.
You can display two responses in the same plot by selecting Overlay Analysis
from the Analysis menu and selecting an available response. A second y-axis is
added to the right side of the response plot. (Note that not all responses can be
overlaid on each other.)
You can also display the filter coefficients and detailed filter information in this
region
For all the analysis methods, except zero-phase response, you can access them
from the Analysis menu, the Analysis Parameters dialog box from the context
menu, or by using the toolbar buttons. For zero-phase, right-click on the y-axis of
the plot and select Zero-phase from the context menu.
Editing the Filter Using the Pole/Zero Editor
Plot mode buttons. Plot mode buttons are located to the left of the pole/zero
plot. Select one of the buttons to change the mode of the pole/zero plot.
The Pole Zero editor has these buttons from left to right: move pole, add pole,
add zero, and delete pole or zero.
The following plot parameters and controls are located to the left of the pole/zero
plot and below the plot mode buttons
Filter gain--factor to compensate for the filter's pole(s) and zero(s) gains
Coordinates--units (Polar or Rectangular) of the selected pole or zero
Magnitude--if polar coordinates is selected, magnitude of the selected pole or
zero
Angle--if polar coordinates is selected, angle of selected pole(s) or zero(s)
Real--if rectangular coordinates is selected, real component of selected
pole(s) or zero(s)
Imaginary--if rectangular coordinates is selected, imaginary component of
selected pole or zero
Section--for multisection filters, number of the current section
Conjugate--creates a corresponding conjugate pole or zero or automatically
selects the conjugate pole or zero if it already exists.
Auto update--immediately updates the displayed magnitude response when
poles or zeros are added, moved, or deleted.
Importing a Filter Design
The Import Filter panel allows you to import a filter. You can access this region by
clicking the Import Filter button in the sidebar.
The imported filter can be in any of the representations listed in the Filter Structure
pull-down menu and described in Filter Structures. You can import a filter as second-
order sections by selecting the check box.
Specify the filter coefficients in Numerator and Denominator, either by entering them
explicitly or by referring to variables in the MATLAB workspace.
Select the frequency units from the following options in the Units menu, and for any
frequency unit other than Normalized, specify the value or MATLAB workspace
variable of the sampling frequency in the Fs field.
To import the filter, click the Import Filter button. The display region is automatically
updated when the new filter has been imported.
You can save the filter either as filter coefficients variables or as a dfilt or mfilt filter
object variable. (Note that you must have the Filter Design Toolbox installed to save
as an mfilt.) To save the filter to the MATLAB workspace:
Select Export from the File menu. The Export dialog box appears.
Select Workspace from the Export To menu.
Select Coefficients from the Export As menu to save the filter coefficients or
select Objects to save the filter in a filter object.
For coefficients, assign variable names using the Numerator (for FIR filters)
or Numerator and Denominator (for IIR filters), or SOS Matrix and Scale
Values (for IIR filters in second-order section form) text boxes in the Variable
Names region. For objects, assign the variable name in the Discrete Filter (or
Quantized Filter) text box. If you have variables with the same names in your
workspace and you want to overwrite them, select the Overwrite Variables
check box.
Click the OK button
Managing Filters in the Current Session
You can store filters designed in the current FDATool session for cascading
together, exporting to FVTool or for recalling later in the same FDATool session.
You store and access saved filters with the Store filter and Filter Manager buttons,
respectively, in the Current Filter Information pane.
Store Filter -- displays the Store Filter dialog box in which you specify the filter name
to use when storing the filter in the Filter Manager. The default name is the type of
the filter.
The current filter is listed below the listbox. To change the current filter,
hightlight the desired filter. If you select Edit current filter, FDATool displays
the current filter and the stored filter is updated with any changes you make to
the filter in FDATool.
To cascade two or more filters, highlight the desired filters and press
Cascade. A new cascaded filter is added to the Filter Manager.
To change the name of a stored filter, press Rename. The Rename filter
dialog box is displayed.
To remove a stored filter from the Filter Manager, press Delete.
To export one or more filters to FVTool, highlight the filter(s) and press
FVTool.
You can save your filter design session as a MAT-file and return to the same
session another time.
Select the Save session button to save your session as a MAT-file. The first time
you save a session, a Save Filter Design File browser opens, prompting you for a
session name.
For example, save this design session as TestFilter.fda in your current working
directory by typing TestFilter in the File name field.
The .fda extension is added automatically to all filter design sessions you save.