SlideShare a Scribd company logo
SAMPLE QUESTION:
Exercise 1: Consider the function
f (x,C)=
sin(C x)
Cx
(a) Create a vector x with 100 elements from -3*pi to 3*pi.
Write f as an inline or anonymous function
and generate the vectors y1 = f(x,C1), y2 = f(x,C2) and y3 =
f(x,C3), where C1 = 1, C2 = 2 and
C3 = 3. Make sure you suppress the output of x and y's
vectors. Plot the function f (for the three
C's above), name the axis, give a title to the plot and include
a legend to identify the plots. Add a
grid to the plot.
(b) Without using inline or anonymous functions write a
function+function structure m-file that does
the same job as in part (a)
SAMPLE LAB WRITEUP:
MAT 275 MATLAB LAB 1
NAME: __________________________
LAB DAY and TIME:______________
Instructor: _______________________
Exercise 1
(a)
x = linspace(-3*pi,3*pi); % generating x vector - default value
for number
% of pts linspace is 100
f= @(x,C) sin(C*x)./(C*x) % C will be just a constant, no need
for ".*"
C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands
y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % supressing the y's
plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers
for
% black and white plots
xlabel('x'), ylabel('y') % labeling the axis
title('f(x,C) = sin(Cx)/(Cx)') % adding a title
legend('C = 1','C = 2','C = 3') % adding a legend
grid on
Command window output:
f =
@(x,C)sin(C*x)./(C*x)
C1 =
1
C2 =
2
C3 =
3
(b)
M-file of structure function+function
function ex1
x = linspace(-3*pi,3*pi); % generating x vector - default value
for number
% of pts linspace is 100
C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands
y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % function f is defined
below
plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers
for
% black and white plots
xlabel('x'), ylabel('y') % labeling the axis
title('f(x,C) = sin(Cx)/(Cx)') % adding a title
legend('C = 1','C = 2','C = 3') % adding a legend
grid on
end
function y = f(x,C)
y = sin(C*x)./(C*x);
end
Command window output:
C1 =
1
C2 =
2
C3 =
3
Joe Bob
Mon lab: 4:30-6:50
Lab 3
Exercise 1
(a) Create function M-file for banded LU factorization
function [L,U] = luband(A,p)
% LUBAND Banded LU factorization
% Adaptation to LUFACT
% Input:
% A diagonally dominant square matrix
% Output:
% L,U unit lower triangular and upper triangular such that
LU=A
n = length(A);
L = eye(n); % ones on diagonal
% Gaussian Elimination
for j = 1:n-1
a = min(j+p,n);
for i = j+1:a
L(i,j) = A(i,j)/A(j,j); % Row multiplier
b = min(j+p-1,n);
A(i,j:b) = A(i,j:b) - L(i,j)*A(j,j:b);
end
end
U = triu(A);
end
(b) Invoke function in command window
>> A = [1 5 3 -1; 2 4 9 9; 1 1 -1 -3; 4 3 10 3] % declare matrix
A
A =
1 5 3 -1
2 4 9 9
1 1 -1 -3
4 3 10 3
>> luband(A, 4) % call luband function from command window
ans =
1.0000 0 0 0
2.0000 1.0000 0 0
1.0000 0.6667 1.0000 0
4.0000 2.8333 1.7500 1.0000
Exercise 2
(a) Create script-file that runs luband function (Lab3_ex2.m)
A = 10*eye(6)+6*diag(ones(5,1),-1)+6*diag(ones(5,1),1);
[Lband, Uband] = luband(A,2);
[L, U] = lu(A);
disp('The original matrix A is ')
disp(A)
disp('Using luband we have')
disp('L = ')
disp(Lband)
disp('U = ')
disp(Uband)
disp('A = ')
disp(Lband*Uband)
disp('Using the built in lu we have')
disp('L = ')
disp(L)
disp('U = ')
disp(U)
disp('A = ')
disp(L*U)
(b) Output in command window
>> Lab3_ex2
The original matrix A is
10 6 0 0 0 0
6 10 6 0 0 0
0 6 10 6 0 0
0 0 6 10 6 0
0 0 0 6 10 6
0 0 0 0 6 10
Using luband we have
L =
1.0000 0 0 0 0 0
0.6000 1.0000 0 0 0 0
0 0.9375 1.0000 0 0 0
0 0 1.3714 1.0000 0 0
0 0 0 3.3871 1.0000 0
0 0 0 0 -0.5813 1.0000
U =
10.0000 6.0000 0 0 0 0
0 6.4000 6.0000 0 0 0
0 0 4.3750 6.0000 0 0
0 0 0 1.7714 6.0000 0
0 0 0 0 -10.3226 6.0000
0 0 0 0 0 13.4875
A =
10 6 0 0 0 0
6 10 6 0 0 0
0 6 10 6 0 0
0 0 6 10 6 0
0 0 0 6 10 6
0 0 0 0 6 10
Using the built in lu we have
L =
1.0000 0 0 0 0 0
0.6000 1.0000 0 0 0 0
0 0.9375 0.7292 -0.2153 -0.3704 1.0000
0 0 1.0000 0 0 0
0 0 0 1.0000 0 0
0 0 0 0 1.0000 0
U =
10.0000 6.0000 0 0 0 0
0 6.4000 6.0000 0 0 0
0 0 6.0000 10.0000 6.0000 0
0 0 0 6.0000 10.0000 6.0000
0 0 0 0 6.0000 10.0000
0 0 0 0 0 4.9954
A =
10.0000 6.0000 0 0 0 0
6.0000 10.0000 6.0000 0 0 0
0 6.0000 10.0000 6.0000 0 0
0 0 6.0000 10.0000 6.0000 0
0 0 0 6.0000 10.0000 6.0000
0 0 0 0 6.0000 10.0000
Exercise 3
(a)
(b)
(c)
.
.
.
.
Exercise 4
.
etc.
MATLAB sessions: Laboratory 1
MAT 275 Laboratory 1
Introduction to MATLAB
MATLAB is a computer software commonly used in both
education and industry to solve a wide range
of problems.
This Laboratory provides a brief introduction to MATLAB, and
the tools and functions that help
you to work with MATLAB variables and files.
The MATLAB Environment
⋆ To start MATLAB double-click on the MATLAB shortcut
icon. The MATLAB desktop will open.
On the left side you will generally find the Current Folder
window and on the right the Workspace
and Command History windows. The Command Window is
where the MATLAB commands are entered
and executed. Note that windows within the MATLAB desktop
can be resized by dragging the separator
bar(s).
If you have never used MATLAB before, we suggest you type
demo at the MATLAB prompt. Click
on Getting Started with MATLAB and run the file.
Basics And Help
Commands are entered in the Command Window.
⋆ Basic operations are +, -, *, and /. The sequence
>> a=2; b=3; a+b, a*b
ans =
5
ans =
6
defines variables a and b and assigns values 2 and 3,
respectively, then computes the sum a+b and product
ab. Each command ends with , (output is visible) or ; (output is
suppressed). The last command on a
line does not require a ,.
⋆ Standard functions can be invoked using their usual
mathematical notations. For example
>> theta=pi/5;
>> cos(theta)^2+sin(theta)^2
ans =
1
verifies the trigonometric identity sin2 θ + cos2 θ = 1 for θ = π
5
. A list of elementary math functions can
be obtained by typing
>> help elfun
⋆ To obtain a description of the use of a particular function
type help followed by the name of the
function. For example
>> help cosh
gives help on the hyperbolic cosine function.
⋆ To get a list of other groups of MATLAB programs already
available enter help:
>> help
c⃝2011 Stefania Tracogna, SoMSS, ASU
MATLAB sessions: Laboratory 1
⋆ Another way to obtain help is through the desktop Help
menu, Help > Product Help.
⋆ MATLAB is case-sensitive. For example
>> theta=1e-3, Theta=2e-5, ratio=theta/Theta
theta =
1.0000e-003
Theta =
2.0000e-005
ratio =
50
⋆ The quantities Inf (∞) and NaN (Not a Number) also appear
frequently. Compare
>> c=1/0
c =
Inf
with
>> d=0/0
d =
NaN
Plotting with MATLAB
⋆ To plot a function you have to create two arrays (vectors):
one containing the abscissae, the other the
corresponding function values. Both arrays should have the
same length. For example, consider plotting
the function
y = f(x) =
x2 − sin(πx) + ex
x − 1
for 0 ≤ x ≤ 2. First choose a sample of x values in this interval:
>> x=[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1, ...
1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2]
x =
Columns 1 through 7
0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000
Columns 8 through 14
0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000
Columns 15 through 21
1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000
Note that an ellipsis ... was used to continue a command too
long to fit in a single line.
Rather than manually entering each entry of the vector x we can
simply use
>> x=0:.1:2
or
>> x=linspace(0,2,21)
Both commands above generate the same output vector x.
⋆ The output for x can be suppressed (by adding ; at the end of
the command) or condensed by entering
>> format compact
c⃝2011 Stefania Tracogna, SoMSS, ASU
MATLAB sessions: Laboratory 1
(This format was used for all previous outputs).
⋆ To evaluate the function f simultaneously at all the values
contained in x, type
>> y=(x.^2-sin(pi.*x)+exp(x))./(x-1)
y =
Columns 1 through 6
-1.0000 -0.8957 -0.8420 -0.9012 -1.1679 -1.7974
Columns 7 through 12
-3.0777 -5.6491 -11.3888 -29.6059 Inf 45.2318
Columns 13 through 18
26.7395 20.5610 17.4156 15.4634 14.1068 13.1042
Columns 19 through 21
12.3468 11.7832 11.3891
Note that the function becomes infinite at x = 1 (vertical
asymptote). The array y inherits the dimension
of x, namely 1 (row) by 21 (columns). Note also the use of
parentheses.
IMPORTANT REMARK
In the above example *, / and ^ are preceded by a dot . in order
for the expression to be evaluated for
each component (entry) of x. This is necessary to prevent
MATLAB from interpreting these symbols
as standard linear algebra symbols operating on arrays. Because
the standard + and - operations on
arrays already work componentwise, a dot is not necessary for +
and -.
The command
>> plot(x,y)
creates a Figure window and shows the function. The figure can
be edited and manipulated using the
Figure window menus and buttons. Alternately, properties of the
figure can also be defined directly at
the command line:
>> x=0:.01:2;
>> y=(x.^2-sin(pi.*x)+exp(x))./(x-1);
>> plot(x,y,’r-’,’LineWidth’,2);
>> axis([0,2,-10,20]); grid on;
>> title(’f(x)=(x^2-sin(pi x)+e^x)/(x-1)’);
>> xlabel(’x’); ylabel(’y’);
Remarks:
• The number of x-values has been increased for a smoother
curve (note that the stepsize is now .01
rather than .1).
• The option ’r-’ plots the curve in red.
• ’LineWidth’,2 sets the width of the line to 2 points (the
default is 0.5).
• The range of x and y values has been reset using axis([0,2,-
10,20]) (always a good idea in the
presence of vertical asymptotes).
• The command grid on adds a grid to the plot.
• A title and labels have been added.
The resulting new plot is shown in Fig. L1a. For more options
type help plot in the Command
Window.
c⃝2011 Stefania Tracogna, SoMSS, ASU
MATLAB sessions: Laboratory 1
Figure L1a: A Figure window
Scripts and Functions
⋆ Files containing MATLAB commands are called m-files and
have a .m extension. They are two types:
1. A script is simply a collection of MATLAB commands
gathered in a single file. The value of the
data created in a script is still available in the Command
Window after execution. To create a
new script select the MATLAB desktop File menu File > New >
Script. In the MATLAB text
editor window enter the commands as you would in the
Command window. To save the file use
the menu File > Save or File > Save As..., or the shortcut SAVE
button .
Variable defined in a script are accessible from the command
window.
2. A function is similar to a script, but can accept and return
arguments. Unless otherwise specified
any variable inside a function is local to the function and not
available in the command window.
To create a new function select the MATLAB desktop File menu
File > New > Function. A
MATLAB text editor window will open with the following
predefined commands
function [ output_args ] = Untitled3( input_args )
%UNTITLED3 Summary of this function goes here
% Detailed explanation goes here
end
The “output args” are the output arguments, while the “input
args” are the input arguments. The
lines beginning with % are to be replaced with comments
describing what the functions does. The
command(s) defining the function must be inserted after these
comments and before end.
To save the file proceed similarly to the Script M-file.
Use a function when a group of commands needs to be evaluated
multiple times.
⋆ Examples of script/function:
1. script
myplot.m
x=0:.01:2; % x-values
y=(x.^2-sin(pi.*x)+exp(x))./(x-1); % y-values
c⃝2011 Stefania Tracogna, SoMSS, ASU
MATLAB sessions: Laboratory 1
plot(x,y,’r-’,’LineWidth’,2); % plot in red with wider line
axis([0,2,-10,20]); grid on; % set range and add grid
title(’f(x)=(x^2-sin(pi x)+e^x)/(x-1)’); % add title
xlabel(’x’); ylabel(’y’); % add labels
2. script+function (two separate files)
myplot2.m (driver script)
x=0:.01:2; % x-values
y=myfunction(x); % evaluate myfunction at x
plot(x,y,’r-’,’LineWidth’,2); % plot in red
axis([0,2,-10,20]); grid on; % set range and add grid
title(’f(x)=(x^2-sin(pi x)+e^x)/(x-1)’); % add title
xlabel(’x’); ylabel(’y’); % add labels
myfunction.m (function)
function y=myfunction(x) % defines function
y=(x.^2-sin(pi.*x)+exp(x))./(x-1); % y-values
3. function+function (one single file)
myplot1.m (driver script converted to function + function)
function myplot1
x=0:.01:2; % x-values
y=myfunction(x); % evaluate myfunction at x
plot(x,y,’r-’,’LineWidth’,2); % plot in red
axis([0,2,-10,20]); grid on; % set range and add grid
title(’f(x)=(x^2-sin(pi x)+e^x)/(x-1)’); % add title
xlabel(’x’); ylabel(’y’); % add labels
%-----------------------------------------
function y=myfunction(x) % defines function
y=(x.^2-sin(pi.*x)+exp(x))./(x-1); % y-values
In case 2 myfunction.m can be used in any other m-file (just as
other predefined MATLAB functions).
In case 3 myfunction.m can be used by any other function in the
same m-file (myplot1.m) only. Use 3
when dealing with a single project and 2 when a function is
used by several projects.
⋆ Note that the function myplot1 does not have explicit input or
output arguments, however we cannot
use a script since the construct script+function in one single file
is not allowed.
⋆ It is convenient to add descriptive comments into the script
file. Anything appearing after % on any
given line is understood as a comment (in green in the
MATLAB text editor).
⋆ To execute a script simply enter its name (without the .m
extension) in the Command Window (or
click on the SAVE & RUN button ).
The function myfunction can also be used independently if
implemented in a separate file myfunction.m:
>> x=2; y=myfunction(x)
y =
11.3891
c⃝2011 Stefania Tracogna, SoMSS, ASU
MATLAB sessions: Laboratory 1
A script can be called from another script or function (in which
case it is local to that function).
If any modification is made, the script or function can be re-
executed by simply retyping the script
or function name in the Command Window (or use the up-arrow
on the keyboard to browse through
past commands).
IMPORTANT REMARK
By default MATLAB saves files in the Current Folder. To
change directory use the Current Directory
box on top of the MATLAB desktop.
⋆ A function file can contain a lot more than a simple
evaluation of a function f(x) or f(t, y). But in
simple cases f(x) or f(t, y) can simply be defined using the
inline syntax.
For instance, if we want to define the function f(t, y) = t2 − y,
we can write the function file f.m
containing
function dydt = f(t,y)
dydt = t^2-y;
and, in the command window, we can evaluate the function at
different values:
>> f(2,1) % evaluate the function f at t = 2 and y = 1
ans =
3
or we can define the function directly on the command line with
the inline command:
>> f = inline(’t^2-y’,’t’,’y’)
f =
Inline function:
f(t,y) = t^2-y
>> f(2,1) % evaluate the function f at t = 2 and y = 1
ans =
3
However, an inline function is only available where it is used
and not to other functions. It is not rec-
ommended when the function implemented is too complicated or
involves too many statements.
Alternatively, the function can be entered as an anonymous
function
>> f = @(t,y)(t^2-y)
⋆ CAUTION!
• The names of script or function M-files must begin with a
letter. The rest of the characters may
include digits and the underscore character. You may not use
periods in the name other than the
last one in ’.m’ and the name cannot contain blank spaces.
• Avoid name clashes with built-in functions. It is a good idea
to first check if a function or a script
file of the proposed name already exists. You can do this with
the command exist(’name’),
which returns zero if nothing with name name exists.
• NEVER name a script file or function file the same as the
name of the variable it computes. When
MATLAB looks for a name, it first searches the list of variables
in the workspace. If a variable of
the same name as the script file exists, MATLAB will never be
able to access the script file.
c⃝2011 Stefania Tracogna, SoMSS, ASU
MATLAB sessions: Laboratory 1
Exercises
Instructions:
You will need to record the results of your MATLAB session to
generate your lab report. Create a
directory (folder) on your computer to save your MATLAB
work in. Then use the Current Directory
field in the desktop toolbar to change the directory to this
folder. Now type
diary lab1 yourname.txt
followed by the Enter key. Now each computation you make in
MATLAB will be save in your directory
in a text file named lab1 yourname.txt. When you have finished
your MATLAB session you can turn
off the recording by typing diary off at the MATLAB prompt.
You can then edit this file using your
favorite text editor (e.g. MS Word).
Lab Write-up: Now that your diary file is open, enter the
command format compact (so that when
you print out your diary file it will not have unnecessary blank
lines), and the comment line
% MAT 275 MATLAB Assignment # 1
Include labels to mark the beginning of your work on each part
of each question, so that your edited lab
write-up has the format
% Exercise 1
.
.
% Exercise 2
Final Editing of Lab Write-up: After you have worked through
all the parts of the lab assignment
you will need to edit your diary file.
• Remove all typing errors.
• Unless otherwise specified, your write-up should contain the
MATLAB input commands,
the corresponding output, and the answers to the questions that
you have written.
• If the exercise asks you to write an M-file, copy and paste the
file into your diary file in the
appropriate position (after the problem number and before the
output generated by the file).
• If the exercise asks for a graph, copy the figure and paste it
into your diary file in the appropriate
position. Crop and resize the figure so that it does not take too
much space. Use “;” to suppress
the output from the vectors used to generate the graph. Make
sure you use enough points for your
graphs so that the resulting curves are nice and smooth.
• Clearly separate all exercises. The exercises’ numbers should
be in a larger format and in boldface.
Preview the document before printing and remove unnecessary
page breaks and blank spaces.
• Put your name and class time on each page.
Important: An unedited diary file without comments submitted
as a lab write-up is not
acceptable.
1. All points with coordinates x = r cos(θ) and y = r sin(θ),
where r is a constant, lie on a circle
with radius r, i.e. satisfy the equation x2 + y2 = r2. Create a
row vector for θ with the values
0, π
4
, π
2
, 3π
4
, π, and 5π
4
.
Take r = 2 and compute the row vectors x and y. Now check that
x and y indeed satisfy the
equation of a circle, by computing the radius r =
√
x2 + y2.
Hint: To calculate r you will need the array operator .^ for
squaring x and y. Of course, you
could also compute x2 by x.*x.
c⃝2011 Stefania Tracogna, SoMSS, ASU
MATLAB sessions: Laboratory 1
2. Use the linspace command or the colon operator : to create a
vector t with 91 elements:
1, 1.1, 1.2, . . . , 10 and define the function y =
et/10 sin(t)
t2 + 1
(make sure you use “;” to suppress
the output for both t and y).
(a) Plot the function y in black and include a title with the
expression for y.
(b) Make the same plot as in part (a), but rather than displaying
the graph as a curve, show the
unconnected data points. To display the data points with small
circles, use plot(t,y,’o’).
Now combine the two plots with the command plot(t,y,’o-’) to
show the line through the
data points as well as the distinct data points.
3. Use the command plot3(x,y,z) to plot the circular helix x(t) =
sin t, y(t) = cos t, z(t) = t
0 ≤ t ≤ 20.
NOTE: Use semicolon to suppress the output when you define
the vectors t, x, y and z. Make sure
you use enough points for your graph so that the resulting curve
is nice and smooth.
4. Plot y = cos x in red with a solid line and z = 1 − x
2
2
+ x
4
24
in blue with a dashed line for 0 ≤ x ≤ π
on the same plot.
Hint: Use plot(x,y,’r’,x,z,’--’).
Add a grid to the plot using the command grid on.
NOTE: Use semicolon to suppress the output when you define
the vectors x, y and z. Make sure
you use enough points for your graph so that the resulting
curves are nice and smooth.
5. The general solution to the differential equation
dy
dx
= x + 2 is
y(x) =
x2
2
+ 2x + C with y(0) = C.
The goal of this exercise is to write a function file to plot the
solutions to the differential equation
in the interval 0 ≤ x ≤ 4, with initial conditions y(0) = −1, 0, 1.
The function file should have the structure function+function
(similarly to the M-file myplot1.m
Example 3, page 5). The function that defines y(x) must be
included in the same file (note that
the function defining y(x) will have two input arguments: x and
C).
Your M-file should have the following structure (fill in all the
?? with the appropriate commands):
function ex5
x = ?? ; % define the vector x in the interval [0,4]
y1 = f(??); % compute the solution with C = -1
y2 = f(??); % compute the solution with C = 0
y3 = f(??); % compute the solution with C = 1
plot(??) % plot the three solutions with different line-styles
title(??) % add a title
legend(??) % add a legend
end
function y = f(x,C)
y = ?? % fill-in with the expression for the general solution
end
Plot the graphs in the same window and use different line-styles
for each graph. To plot the graphs
in the same window you can use the command hold on or use
the plot command similarly to
Exercise 4.
Add the title ’
Solution
s to dy/dx = x + 2’.
Add a legend on the top left corner of the plot with the list of C
values used for each graph.
c⃝2011 Stefania Tracogna, SoMSS, ASU
MATLAB sessions: Laboratory 1
(Type help plot for a list of the different line-styles, and help
legend for help on how to add a
legend.) Include both the M-file and the plot in your report.
NOTE: the only output of the function file should be the graph
of the three curves. Make sure
you use enough points so that the curves are nice and smooth.
6. (a) Enter the function f(x, y) = x3 +
yex
x + 1
as an inline or anonymous function (see page 6).
Evaluate the function at x = 2 and y = −1.
(b) Type clear f to clear the value of the function from part (a).
Now write a function M-file
for the function f(x, y) = x3 +
yex
x + 1
. Save the file as f.m (include the M-file in your report).
Evaluate the function at x = 2 and y = −1 by entering f(2,-1) in
the command window.
c⃝2011 Stefania Tracogna, SoMSS, ASU

More Related Content

Similar to SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx

Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docxLab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
smile790243
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projects
Mukesh Kumar
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
Manchireddy Reddy
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
raghav415187
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
andreecapon
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
BilawalBaloch1
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2bilawalali74
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABFundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLAB
Ali Ghanbarzadeh
 
Programming with matlab session 1
Programming with matlab session 1Programming with matlab session 1
Programming with matlab session 1
Infinity Tech Solutions
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance HaskellJohan Tibell
 
1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx
BeheraA
 
Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3
AhsanIrshad8
 
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docxMATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
andreecapon
 
Basic of octave matlab programming language
Basic of octave matlab programming languageBasic of octave matlab programming language
Basic of octave matlab programming language
Aulia Khalqillah
 
1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
SungaleliYuen
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
naveen_setty
 

Similar to SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx (20)

Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docxLab 5 template  Lab 5 - Your Name - MAT 275 Lab The M.docx
Lab 5 template Lab 5 - Your Name - MAT 275 Lab The M.docx
 
A complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projectsA complete introduction on matlab and matlab's projects
A complete introduction on matlab and matlab's projects
 
bobok
bobokbobok
bobok
 
B61301007 matlab documentation
B61301007 matlab documentationB61301007 matlab documentation
B61301007 matlab documentation
 
presentation.pptx
presentation.pptxpresentation.pptx
presentation.pptx
 
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docxMATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
MATLAB sessions Laboratory 2MAT 275 Laboratory 2Matrix .docx
 
Introduction to matlab
Introduction to matlabIntroduction to matlab
Introduction to matlab
 
Dsp manual completed2
Dsp manual completed2Dsp manual completed2
Dsp manual completed2
 
Matlabtut1
Matlabtut1Matlabtut1
Matlabtut1
 
Matlab booklet
Matlab bookletMatlab booklet
Matlab booklet
 
Fundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLABFundamentals of Image Processing & Computer Vision with MATLAB
Fundamentals of Image Processing & Computer Vision with MATLAB
 
Programming with matlab session 1
Programming with matlab session 1Programming with matlab session 1
Programming with matlab session 1
 
High-Performance Haskell
High-Performance HaskellHigh-Performance Haskell
High-Performance Haskell
 
1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx1.1Introduction to matlab.pptx
1.1Introduction to matlab.pptx
 
Solution of matlab chapter 3
Solution of matlab chapter 3Solution of matlab chapter 3
Solution of matlab chapter 3
 
Learn Matlab
Learn MatlabLearn Matlab
Learn Matlab
 
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docxMATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
MATLAB sessions Laboratory 1MAT 275 Laboratory 1Introdu.docx
 
Basic of octave matlab programming language
Basic of octave matlab programming languageBasic of octave matlab programming language
Basic of octave matlab programming language
 
1. Introduction.pptx
1. Introduction.pptx1. Introduction.pptx
1. Introduction.pptx
 
matlab_tutorial.ppt
matlab_tutorial.pptmatlab_tutorial.ppt
matlab_tutorial.ppt
 

More from agnesdcarey33086

Sample Summaries of Emily Raine’s Why Should I Be Nice to You.docx
Sample Summaries of Emily Raine’s Why Should I Be Nice to You.docxSample Summaries of Emily Raine’s Why Should I Be Nice to You.docx
Sample Summaries of Emily Raine’s Why Should I Be Nice to You.docx
agnesdcarey33086
 
SAMPLEExecutive Summary The following report is an evalua.docx
SAMPLEExecutive Summary The following report is an evalua.docxSAMPLEExecutive Summary The following report is an evalua.docx
SAMPLEExecutive Summary The following report is an evalua.docx
agnesdcarey33086
 
Sample Student Industry AnalysisExecutive SummaryCom.docx
Sample Student Industry AnalysisExecutive SummaryCom.docxSample Student Industry AnalysisExecutive SummaryCom.docx
Sample Student Industry AnalysisExecutive SummaryCom.docx
agnesdcarey33086
 
sample.sql-- START-- SETUP Create userCREATE USER .docx
sample.sql-- START-- SETUP Create userCREATE USER .docxsample.sql-- START-- SETUP Create userCREATE USER .docx
sample.sql-- START-- SETUP Create userCREATE USER .docx
agnesdcarey33086
 
SAMPLING MEAN DEFINITION The term sampling mean is.docx
SAMPLING MEAN  DEFINITION  The term sampling mean is.docxSAMPLING MEAN  DEFINITION  The term sampling mean is.docx
SAMPLING MEAN DEFINITION The term sampling mean is.docx
agnesdcarey33086
 
SAMPLING MEANDEFINITIONThe term sampling mean is a stati.docx
SAMPLING MEANDEFINITIONThe term sampling mean is a stati.docxSAMPLING MEANDEFINITIONThe term sampling mean is a stati.docx
SAMPLING MEANDEFINITIONThe term sampling mean is a stati.docx
agnesdcarey33086
 
sampleReportt.docxPower Electronics Contents.docx
sampleReportt.docxPower Electronics            Contents.docxsampleReportt.docxPower Electronics            Contents.docx
sampleReportt.docxPower Electronics Contents.docx
agnesdcarey33086
 
Sample Workflow of Answering a Telephone in an OfficeInform .docx
Sample Workflow of Answering a Telephone in an OfficeInform .docxSample Workflow of Answering a Telephone in an OfficeInform .docx
Sample Workflow of Answering a Telephone in an OfficeInform .docx
agnesdcarey33086
 
Sample Investment PropertyAverage InlandSan Diego HomeASSUMPTION.docx
Sample Investment PropertyAverage InlandSan Diego HomeASSUMPTION.docxSample Investment PropertyAverage InlandSan Diego HomeASSUMPTION.docx
Sample Investment PropertyAverage InlandSan Diego HomeASSUMPTION.docx
agnesdcarey33086
 
SAMPLE Project (Answers and explanations are in red)I opened t.docx
SAMPLE Project (Answers and explanations are in red)I opened t.docxSAMPLE Project (Answers and explanations are in red)I opened t.docx
SAMPLE Project (Answers and explanations are in red)I opened t.docx
agnesdcarey33086
 
Sample Questions to Ask During an Informational Interview .docx
Sample Questions to Ask During an Informational Interview  .docxSample Questions to Ask During an Informational Interview  .docx
Sample Questions to Ask During an Informational Interview .docx
agnesdcarey33086
 
Sample Table.pdfTopic RatingPatients Goal Able to walk .docx
Sample Table.pdfTopic RatingPatients Goal Able to walk .docxSample Table.pdfTopic RatingPatients Goal Able to walk .docx
Sample Table.pdfTopic RatingPatients Goal Able to walk .docx
agnesdcarey33086
 
Sample PowerPoint Flow Week 5Select a current product with which.docx
Sample PowerPoint Flow Week 5Select a current product with which.docxSample PowerPoint Flow Week 5Select a current product with which.docx
Sample PowerPoint Flow Week 5Select a current product with which.docx
agnesdcarey33086
 
Sample Of assignmentIntroductionComment by Jane Summers Introd.docx
Sample Of assignmentIntroductionComment by Jane Summers Introd.docxSample Of assignmentIntroductionComment by Jane Summers Introd.docx
Sample Of assignmentIntroductionComment by Jane Summers Introd.docx
agnesdcarey33086
 
Sample Access Control Policy1.Purpose2.Scope3.Pol.docx
Sample Access Control Policy1.Purpose2.Scope3.Pol.docxSample Access Control Policy1.Purpose2.Scope3.Pol.docx
Sample Access Control Policy1.Purpose2.Scope3.Pol.docx
agnesdcarey33086
 
SAMPLE GED 501 RESEARCH PAPERTechnology Based Education How.docx
SAMPLE GED 501 RESEARCH PAPERTechnology Based Education How.docxSAMPLE GED 501 RESEARCH PAPERTechnology Based Education How.docx
SAMPLE GED 501 RESEARCH PAPERTechnology Based Education How.docx
agnesdcarey33086
 
Sample Action Research Report 1 Effect of Technol.docx
Sample Action Research Report 1    Effect of Technol.docxSample Action Research Report 1    Effect of Technol.docx
Sample Action Research Report 1 Effect of Technol.docx
agnesdcarey33086
 
Sample Case with a report Dawit Zerom, Instructor Cas.docx
Sample Case with a report Dawit Zerom, Instructor  Cas.docxSample Case with a report Dawit Zerom, Instructor  Cas.docx
Sample Case with a report Dawit Zerom, Instructor Cas.docx
agnesdcarey33086
 
Salkind_datasetsCrab Scale Results.savSalkind_datasetsLess.docx
Salkind_datasetsCrab Scale Results.savSalkind_datasetsLess.docxSalkind_datasetsCrab Scale Results.savSalkind_datasetsLess.docx
Salkind_datasetsCrab Scale Results.savSalkind_datasetsLess.docx
agnesdcarey33086
 
Sales_Marketing_-_Riordan_9.docxSales & MarketingHome .docx
Sales_Marketing_-_Riordan_9.docxSales & MarketingHome  .docxSales_Marketing_-_Riordan_9.docxSales & MarketingHome  .docx
Sales_Marketing_-_Riordan_9.docxSales & MarketingHome .docx
agnesdcarey33086
 

More from agnesdcarey33086 (20)

Sample Summaries of Emily Raine’s Why Should I Be Nice to You.docx
Sample Summaries of Emily Raine’s Why Should I Be Nice to You.docxSample Summaries of Emily Raine’s Why Should I Be Nice to You.docx
Sample Summaries of Emily Raine’s Why Should I Be Nice to You.docx
 
SAMPLEExecutive Summary The following report is an evalua.docx
SAMPLEExecutive Summary The following report is an evalua.docxSAMPLEExecutive Summary The following report is an evalua.docx
SAMPLEExecutive Summary The following report is an evalua.docx
 
Sample Student Industry AnalysisExecutive SummaryCom.docx
Sample Student Industry AnalysisExecutive SummaryCom.docxSample Student Industry AnalysisExecutive SummaryCom.docx
Sample Student Industry AnalysisExecutive SummaryCom.docx
 
sample.sql-- START-- SETUP Create userCREATE USER .docx
sample.sql-- START-- SETUP Create userCREATE USER .docxsample.sql-- START-- SETUP Create userCREATE USER .docx
sample.sql-- START-- SETUP Create userCREATE USER .docx
 
SAMPLING MEAN DEFINITION The term sampling mean is.docx
SAMPLING MEAN  DEFINITION  The term sampling mean is.docxSAMPLING MEAN  DEFINITION  The term sampling mean is.docx
SAMPLING MEAN DEFINITION The term sampling mean is.docx
 
SAMPLING MEANDEFINITIONThe term sampling mean is a stati.docx
SAMPLING MEANDEFINITIONThe term sampling mean is a stati.docxSAMPLING MEANDEFINITIONThe term sampling mean is a stati.docx
SAMPLING MEANDEFINITIONThe term sampling mean is a stati.docx
 
sampleReportt.docxPower Electronics Contents.docx
sampleReportt.docxPower Electronics            Contents.docxsampleReportt.docxPower Electronics            Contents.docx
sampleReportt.docxPower Electronics Contents.docx
 
Sample Workflow of Answering a Telephone in an OfficeInform .docx
Sample Workflow of Answering a Telephone in an OfficeInform .docxSample Workflow of Answering a Telephone in an OfficeInform .docx
Sample Workflow of Answering a Telephone in an OfficeInform .docx
 
Sample Investment PropertyAverage InlandSan Diego HomeASSUMPTION.docx
Sample Investment PropertyAverage InlandSan Diego HomeASSUMPTION.docxSample Investment PropertyAverage InlandSan Diego HomeASSUMPTION.docx
Sample Investment PropertyAverage InlandSan Diego HomeASSUMPTION.docx
 
SAMPLE Project (Answers and explanations are in red)I opened t.docx
SAMPLE Project (Answers and explanations are in red)I opened t.docxSAMPLE Project (Answers and explanations are in red)I opened t.docx
SAMPLE Project (Answers and explanations are in red)I opened t.docx
 
Sample Questions to Ask During an Informational Interview .docx
Sample Questions to Ask During an Informational Interview  .docxSample Questions to Ask During an Informational Interview  .docx
Sample Questions to Ask During an Informational Interview .docx
 
Sample Table.pdfTopic RatingPatients Goal Able to walk .docx
Sample Table.pdfTopic RatingPatients Goal Able to walk .docxSample Table.pdfTopic RatingPatients Goal Able to walk .docx
Sample Table.pdfTopic RatingPatients Goal Able to walk .docx
 
Sample PowerPoint Flow Week 5Select a current product with which.docx
Sample PowerPoint Flow Week 5Select a current product with which.docxSample PowerPoint Flow Week 5Select a current product with which.docx
Sample PowerPoint Flow Week 5Select a current product with which.docx
 
Sample Of assignmentIntroductionComment by Jane Summers Introd.docx
Sample Of assignmentIntroductionComment by Jane Summers Introd.docxSample Of assignmentIntroductionComment by Jane Summers Introd.docx
Sample Of assignmentIntroductionComment by Jane Summers Introd.docx
 
Sample Access Control Policy1.Purpose2.Scope3.Pol.docx
Sample Access Control Policy1.Purpose2.Scope3.Pol.docxSample Access Control Policy1.Purpose2.Scope3.Pol.docx
Sample Access Control Policy1.Purpose2.Scope3.Pol.docx
 
SAMPLE GED 501 RESEARCH PAPERTechnology Based Education How.docx
SAMPLE GED 501 RESEARCH PAPERTechnology Based Education How.docxSAMPLE GED 501 RESEARCH PAPERTechnology Based Education How.docx
SAMPLE GED 501 RESEARCH PAPERTechnology Based Education How.docx
 
Sample Action Research Report 1 Effect of Technol.docx
Sample Action Research Report 1    Effect of Technol.docxSample Action Research Report 1    Effect of Technol.docx
Sample Action Research Report 1 Effect of Technol.docx
 
Sample Case with a report Dawit Zerom, Instructor Cas.docx
Sample Case with a report Dawit Zerom, Instructor  Cas.docxSample Case with a report Dawit Zerom, Instructor  Cas.docx
Sample Case with a report Dawit Zerom, Instructor Cas.docx
 
Salkind_datasetsCrab Scale Results.savSalkind_datasetsLess.docx
Salkind_datasetsCrab Scale Results.savSalkind_datasetsLess.docxSalkind_datasetsCrab Scale Results.savSalkind_datasetsLess.docx
Salkind_datasetsCrab Scale Results.savSalkind_datasetsLess.docx
 
Sales_Marketing_-_Riordan_9.docxSales & MarketingHome .docx
Sales_Marketing_-_Riordan_9.docxSales & MarketingHome  .docxSales_Marketing_-_Riordan_9.docxSales & MarketingHome  .docx
Sales_Marketing_-_Riordan_9.docxSales & MarketingHome .docx
 

Recently uploaded

Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
GeoBlogs
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
Col Mukteshwar Prasad
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
siemaillard
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
kaushalkr1407
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
Jisc
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
Fundacja Rozwoju Społeczeństwa Przedsiębiorczego
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
rosedainty
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
beazzy04
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
Vivekanand Anglo Vedic Academy
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
Celine George
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
Special education needs
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
Vikramjit Singh
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
Celine George
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
Anna Sz.
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
Sandy Millin
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
Mohd Adib Abd Muin, Senior Lecturer at Universiti Utara Malaysia
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
Pavel ( NSTU)
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
GeoBlogs
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
BhavyaRajput3
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
RaedMohamed3
 

Recently uploaded (20)

Fish and Chips - have they had their chips
Fish and Chips - have they had their chipsFish and Chips - have they had their chips
Fish and Chips - have they had their chips
 
How to Break the cycle of negative Thoughts
How to Break the cycle of negative ThoughtsHow to Break the cycle of negative Thoughts
How to Break the cycle of negative Thoughts
 
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa
 
The Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdfThe Roman Empire A Historical Colossus.pdf
The Roman Empire A Historical Colossus.pdf
 
The approach at University of Liverpool.pptx
The approach at University of Liverpool.pptxThe approach at University of Liverpool.pptx
The approach at University of Liverpool.pptx
 
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdfESC Beyond Borders _From EU to You_ InfoPack general.pdf
ESC Beyond Borders _From EU to You_ InfoPack general.pdf
 
Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)Template Jadual Bertugas Kelas (Boleh Edit)
Template Jadual Bertugas Kelas (Boleh Edit)
 
Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345Sha'Carri Richardson Presentation 202345
Sha'Carri Richardson Presentation 202345
 
Sectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdfSectors of the Indian Economy - Class 10 Study Notes pdf
Sectors of the Indian Economy - Class 10 Study Notes pdf
 
How to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS ModuleHow to Split Bills in the Odoo 17 POS Module
How to Split Bills in the Odoo 17 POS Module
 
special B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdfspecial B.ed 2nd year old paper_20240531.pdf
special B.ed 2nd year old paper_20240531.pdf
 
Digital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and ResearchDigital Tools and AI for Teaching Learning and Research
Digital Tools and AI for Teaching Learning and Research
 
Model Attribute Check Company Auto Property
Model Attribute  Check Company Auto PropertyModel Attribute  Check Company Auto Property
Model Attribute Check Company Auto Property
 
Polish students' mobility in the Czech Republic
Polish students' mobility in the Czech RepublicPolish students' mobility in the Czech Republic
Polish students' mobility in the Czech Republic
 
2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...2024.06.01 Introducing a competency framework for languag learning materials ...
2024.06.01 Introducing a competency framework for languag learning materials ...
 
Chapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptxChapter 3 - Islamic Banking Products and Services.pptx
Chapter 3 - Islamic Banking Products and Services.pptx
 
Synthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptxSynthetic Fiber Construction in lab .pptx
Synthetic Fiber Construction in lab .pptx
 
The geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideasThe geography of Taylor Swift - some ideas
The geography of Taylor Swift - some ideas
 
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCECLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
CLASS 11 CBSE B.St Project AIDS TO TRADE - INSURANCE
 
Palestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptxPalestine last event orientationfvgnh .pptx
Palestine last event orientationfvgnh .pptx
 

SAMPLE QUESTIONExercise 1 Consider the functionf (x,C).docx

  • 1. SAMPLE QUESTION: Exercise 1: Consider the function f (x,C)= sin(C x) Cx (a) Create a vector x with 100 elements from -3*pi to 3*pi. Write f as an inline or anonymous function and generate the vectors y1 = f(x,C1), y2 = f(x,C2) and y3 = f(x,C3), where C1 = 1, C2 = 2 and C3 = 3. Make sure you suppress the output of x and y's vectors. Plot the function f (for the three C's above), name the axis, give a title to the plot and include a legend to identify the plots. Add a grid to the plot. (b) Without using inline or anonymous functions write a function+function structure m-file that does the same job as in part (a) SAMPLE LAB WRITEUP: MAT 275 MATLAB LAB 1 NAME: __________________________ LAB DAY and TIME:______________ Instructor: _______________________
  • 2. Exercise 1 (a) x = linspace(-3*pi,3*pi); % generating x vector - default value for number % of pts linspace is 100 f= @(x,C) sin(C*x)./(C*x) % C will be just a constant, no need for ".*" C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % supressing the y's plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers for % black and white plots xlabel('x'), ylabel('y') % labeling the axis title('f(x,C) = sin(Cx)/(Cx)') % adding a title legend('C = 1','C = 2','C = 3') % adding a legend grid on Command window output: f = @(x,C)sin(C*x)./(C*x) C1 = 1 C2 = 2 C3 =
  • 3. 3 (b) M-file of structure function+function function ex1 x = linspace(-3*pi,3*pi); % generating x vector - default value for number % of pts linspace is 100 C1 = 1, C2 = 2, C3 = 3 % Using commans to separate commands y1 = f(x,C1); y2 = f(x,C2); y3 = f(x,C3); % function f is defined below plot(x,y1,'b.-', x,y2,'ro-', x,y3,'ks-') % using different markers for % black and white plots xlabel('x'), ylabel('y') % labeling the axis title('f(x,C) = sin(Cx)/(Cx)') % adding a title legend('C = 1','C = 2','C = 3') % adding a legend grid on end function y = f(x,C) y = sin(C*x)./(C*x); end Command window output: C1 = 1 C2 =
  • 4. 2 C3 = 3 Joe Bob Mon lab: 4:30-6:50 Lab 3 Exercise 1 (a) Create function M-file for banded LU factorization function [L,U] = luband(A,p) % LUBAND Banded LU factorization % Adaptation to LUFACT % Input: % A diagonally dominant square matrix % Output: % L,U unit lower triangular and upper triangular such that LU=A n = length(A); L = eye(n); % ones on diagonal % Gaussian Elimination
  • 5. for j = 1:n-1 a = min(j+p,n); for i = j+1:a L(i,j) = A(i,j)/A(j,j); % Row multiplier b = min(j+p-1,n); A(i,j:b) = A(i,j:b) - L(i,j)*A(j,j:b); end end U = triu(A); end (b) Invoke function in command window >> A = [1 5 3 -1; 2 4 9 9; 1 1 -1 -3; 4 3 10 3] % declare matrix A A = 1 5 3 -1 2 4 9 9 1 1 -1 -3 4 3 10 3 >> luband(A, 4) % call luband function from command window
  • 6. ans = 1.0000 0 0 0 2.0000 1.0000 0 0 1.0000 0.6667 1.0000 0 4.0000 2.8333 1.7500 1.0000 Exercise 2 (a) Create script-file that runs luband function (Lab3_ex2.m) A = 10*eye(6)+6*diag(ones(5,1),-1)+6*diag(ones(5,1),1); [Lband, Uband] = luband(A,2); [L, U] = lu(A); disp('The original matrix A is ') disp(A) disp('Using luband we have') disp('L = ') disp(Lband) disp('U = ') disp(Uband) disp('A = ')
  • 7. disp(Lband*Uband) disp('Using the built in lu we have') disp('L = ') disp(L) disp('U = ') disp(U) disp('A = ') disp(L*U) (b) Output in command window >> Lab3_ex2 The original matrix A is 10 6 0 0 0 0 6 10 6 0 0 0 0 6 10 6 0 0 0 0 6 10 6 0 0 0 0 6 10 6 0 0 0 0 6 10 Using luband we have L =
  • 8. 1.0000 0 0 0 0 0 0.6000 1.0000 0 0 0 0 0 0.9375 1.0000 0 0 0 0 0 1.3714 1.0000 0 0 0 0 0 3.3871 1.0000 0 0 0 0 0 -0.5813 1.0000 U = 10.0000 6.0000 0 0 0 0 0 6.4000 6.0000 0 0 0 0 0 4.3750 6.0000 0 0 0 0 0 1.7714 6.0000 0 0 0 0 0 -10.3226 6.0000 0 0 0 0 0 13.4875 A = 10 6 0 0 0 0 6 10 6 0 0 0
  • 9. 0 6 10 6 0 0 0 0 6 10 6 0 0 0 0 6 10 6 0 0 0 0 6 10 Using the built in lu we have L = 1.0000 0 0 0 0 0 0.6000 1.0000 0 0 0 0 0 0.9375 0.7292 -0.2153 -0.3704 1.0000 0 0 1.0000 0 0 0 0 0 0 1.0000 0 0 0 0 0 0 1.0000 0 U = 10.0000 6.0000 0 0 0 0 0 6.4000 6.0000 0 0 0 0 0 6.0000 10.0000 6.0000 0 0 0 0 6.0000 10.0000 6.0000
  • 10. 0 0 0 0 6.0000 10.0000 0 0 0 0 0 4.9954 A = 10.0000 6.0000 0 0 0 0 6.0000 10.0000 6.0000 0 0 0 0 6.0000 10.0000 6.0000 0 0 0 0 6.0000 10.0000 6.0000 0 0 0 0 6.0000 10.0000 6.0000 0 0 0 0 6.0000 10.0000 Exercise 3 (a) (b) (c) . . . .
  • 11. Exercise 4 . etc. MATLAB sessions: Laboratory 1 MAT 275 Laboratory 1 Introduction to MATLAB MATLAB is a computer software commonly used in both education and industry to solve a wide range of problems. This Laboratory provides a brief introduction to MATLAB, and the tools and functions that help you to work with MATLAB variables and files. The MATLAB Environment ⋆ To start MATLAB double-click on the MATLAB shortcut icon. The MATLAB desktop will open. On the left side you will generally find the Current Folder window and on the right the Workspace and Command History windows. The Command Window is where the MATLAB commands are entered and executed. Note that windows within the MATLAB desktop can be resized by dragging the separator bar(s). If you have never used MATLAB before, we suggest you type
  • 12. demo at the MATLAB prompt. Click on Getting Started with MATLAB and run the file. Basics And Help Commands are entered in the Command Window. ⋆ Basic operations are +, -, *, and /. The sequence >> a=2; b=3; a+b, a*b ans = 5 ans = 6 defines variables a and b and assigns values 2 and 3, respectively, then computes the sum a+b and product ab. Each command ends with , (output is visible) or ; (output is suppressed). The last command on a line does not require a ,. ⋆ Standard functions can be invoked using their usual mathematical notations. For example >> theta=pi/5; >> cos(theta)^2+sin(theta)^2 ans = 1 verifies the trigonometric identity sin2 θ + cos2 θ = 1 for θ = π 5
  • 13. . A list of elementary math functions can be obtained by typing >> help elfun ⋆ To obtain a description of the use of a particular function type help followed by the name of the function. For example >> help cosh gives help on the hyperbolic cosine function. ⋆ To get a list of other groups of MATLAB programs already available enter help: >> help c⃝2011 Stefania Tracogna, SoMSS, ASU MATLAB sessions: Laboratory 1 ⋆ Another way to obtain help is through the desktop Help menu, Help > Product Help. ⋆ MATLAB is case-sensitive. For example >> theta=1e-3, Theta=2e-5, ratio=theta/Theta theta = 1.0000e-003 Theta =
  • 14. 2.0000e-005 ratio = 50 ⋆ The quantities Inf (∞) and NaN (Not a Number) also appear frequently. Compare >> c=1/0 c = Inf with >> d=0/0 d = NaN Plotting with MATLAB ⋆ To plot a function you have to create two arrays (vectors): one containing the abscissae, the other the corresponding function values. Both arrays should have the same length. For example, consider plotting the function y = f(x) = x2 − sin(πx) + ex x − 1
  • 15. for 0 ≤ x ≤ 2. First choose a sample of x values in this interval: >> x=[0,.1,.2,.3,.4,.5,.6,.7,.8,.9,1, ... 1.1,1.2,1.3,1.4,1.5,1.6,1.7,1.8,1.9,2] x = Columns 1 through 7 0 0.1000 0.2000 0.3000 0.4000 0.5000 0.6000 Columns 8 through 14 0.7000 0.8000 0.9000 1.0000 1.1000 1.2000 1.3000 Columns 15 through 21 1.4000 1.5000 1.6000 1.7000 1.8000 1.9000 2.0000 Note that an ellipsis ... was used to continue a command too long to fit in a single line. Rather than manually entering each entry of the vector x we can simply use >> x=0:.1:2 or >> x=linspace(0,2,21) Both commands above generate the same output vector x. ⋆ The output for x can be suppressed (by adding ; at the end of the command) or condensed by entering
  • 16. >> format compact c⃝2011 Stefania Tracogna, SoMSS, ASU MATLAB sessions: Laboratory 1 (This format was used for all previous outputs). ⋆ To evaluate the function f simultaneously at all the values contained in x, type >> y=(x.^2-sin(pi.*x)+exp(x))./(x-1) y = Columns 1 through 6 -1.0000 -0.8957 -0.8420 -0.9012 -1.1679 -1.7974 Columns 7 through 12 -3.0777 -5.6491 -11.3888 -29.6059 Inf 45.2318 Columns 13 through 18 26.7395 20.5610 17.4156 15.4634 14.1068 13.1042 Columns 19 through 21 12.3468 11.7832 11.3891 Note that the function becomes infinite at x = 1 (vertical asymptote). The array y inherits the dimension of x, namely 1 (row) by 21 (columns). Note also the use of
  • 17. parentheses. IMPORTANT REMARK In the above example *, / and ^ are preceded by a dot . in order for the expression to be evaluated for each component (entry) of x. This is necessary to prevent MATLAB from interpreting these symbols as standard linear algebra symbols operating on arrays. Because the standard + and - operations on arrays already work componentwise, a dot is not necessary for + and -. The command >> plot(x,y) creates a Figure window and shows the function. The figure can be edited and manipulated using the Figure window menus and buttons. Alternately, properties of the figure can also be defined directly at the command line: >> x=0:.01:2; >> y=(x.^2-sin(pi.*x)+exp(x))./(x-1); >> plot(x,y,’r-’,’LineWidth’,2); >> axis([0,2,-10,20]); grid on; >> title(’f(x)=(x^2-sin(pi x)+e^x)/(x-1)’); >> xlabel(’x’); ylabel(’y’); Remarks:
  • 18. • The number of x-values has been increased for a smoother curve (note that the stepsize is now .01 rather than .1). • The option ’r-’ plots the curve in red. • ’LineWidth’,2 sets the width of the line to 2 points (the default is 0.5). • The range of x and y values has been reset using axis([0,2,- 10,20]) (always a good idea in the presence of vertical asymptotes). • The command grid on adds a grid to the plot. • A title and labels have been added. The resulting new plot is shown in Fig. L1a. For more options type help plot in the Command Window. c⃝2011 Stefania Tracogna, SoMSS, ASU MATLAB sessions: Laboratory 1 Figure L1a: A Figure window Scripts and Functions ⋆ Files containing MATLAB commands are called m-files and have a .m extension. They are two types: 1. A script is simply a collection of MATLAB commands gathered in a single file. The value of the
  • 19. data created in a script is still available in the Command Window after execution. To create a new script select the MATLAB desktop File menu File > New > Script. In the MATLAB text editor window enter the commands as you would in the Command window. To save the file use the menu File > Save or File > Save As..., or the shortcut SAVE button . Variable defined in a script are accessible from the command window. 2. A function is similar to a script, but can accept and return arguments. Unless otherwise specified any variable inside a function is local to the function and not available in the command window. To create a new function select the MATLAB desktop File menu File > New > Function. A MATLAB text editor window will open with the following predefined commands function [ output_args ] = Untitled3( input_args ) %UNTITLED3 Summary of this function goes here % Detailed explanation goes here end The “output args” are the output arguments, while the “input args” are the input arguments. The lines beginning with % are to be replaced with comments describing what the functions does. The command(s) defining the function must be inserted after these comments and before end. To save the file proceed similarly to the Script M-file.
  • 20. Use a function when a group of commands needs to be evaluated multiple times. ⋆ Examples of script/function: 1. script myplot.m x=0:.01:2; % x-values y=(x.^2-sin(pi.*x)+exp(x))./(x-1); % y-values c⃝2011 Stefania Tracogna, SoMSS, ASU MATLAB sessions: Laboratory 1 plot(x,y,’r-’,’LineWidth’,2); % plot in red with wider line axis([0,2,-10,20]); grid on; % set range and add grid title(’f(x)=(x^2-sin(pi x)+e^x)/(x-1)’); % add title xlabel(’x’); ylabel(’y’); % add labels 2. script+function (two separate files) myplot2.m (driver script) x=0:.01:2; % x-values y=myfunction(x); % evaluate myfunction at x
  • 21. plot(x,y,’r-’,’LineWidth’,2); % plot in red axis([0,2,-10,20]); grid on; % set range and add grid title(’f(x)=(x^2-sin(pi x)+e^x)/(x-1)’); % add title xlabel(’x’); ylabel(’y’); % add labels myfunction.m (function) function y=myfunction(x) % defines function y=(x.^2-sin(pi.*x)+exp(x))./(x-1); % y-values 3. function+function (one single file) myplot1.m (driver script converted to function + function) function myplot1 x=0:.01:2; % x-values y=myfunction(x); % evaluate myfunction at x plot(x,y,’r-’,’LineWidth’,2); % plot in red axis([0,2,-10,20]); grid on; % set range and add grid title(’f(x)=(x^2-sin(pi x)+e^x)/(x-1)’); % add title xlabel(’x’); ylabel(’y’); % add labels %----------------------------------------- function y=myfunction(x) % defines function
  • 22. y=(x.^2-sin(pi.*x)+exp(x))./(x-1); % y-values In case 2 myfunction.m can be used in any other m-file (just as other predefined MATLAB functions). In case 3 myfunction.m can be used by any other function in the same m-file (myplot1.m) only. Use 3 when dealing with a single project and 2 when a function is used by several projects. ⋆ Note that the function myplot1 does not have explicit input or output arguments, however we cannot use a script since the construct script+function in one single file is not allowed. ⋆ It is convenient to add descriptive comments into the script file. Anything appearing after % on any given line is understood as a comment (in green in the MATLAB text editor). ⋆ To execute a script simply enter its name (without the .m extension) in the Command Window (or click on the SAVE & RUN button ). The function myfunction can also be used independently if implemented in a separate file myfunction.m: >> x=2; y=myfunction(x) y = 11.3891 c⃝2011 Stefania Tracogna, SoMSS, ASU
  • 23. MATLAB sessions: Laboratory 1 A script can be called from another script or function (in which case it is local to that function). If any modification is made, the script or function can be re- executed by simply retyping the script or function name in the Command Window (or use the up-arrow on the keyboard to browse through past commands). IMPORTANT REMARK By default MATLAB saves files in the Current Folder. To change directory use the Current Directory box on top of the MATLAB desktop. ⋆ A function file can contain a lot more than a simple evaluation of a function f(x) or f(t, y). But in simple cases f(x) or f(t, y) can simply be defined using the inline syntax. For instance, if we want to define the function f(t, y) = t2 − y, we can write the function file f.m containing function dydt = f(t,y) dydt = t^2-y; and, in the command window, we can evaluate the function at different values: >> f(2,1) % evaluate the function f at t = 2 and y = 1 ans =
  • 24. 3 or we can define the function directly on the command line with the inline command: >> f = inline(’t^2-y’,’t’,’y’) f = Inline function: f(t,y) = t^2-y >> f(2,1) % evaluate the function f at t = 2 and y = 1 ans = 3 However, an inline function is only available where it is used and not to other functions. It is not rec- ommended when the function implemented is too complicated or involves too many statements. Alternatively, the function can be entered as an anonymous function >> f = @(t,y)(t^2-y) ⋆ CAUTION! • The names of script or function M-files must begin with a letter. The rest of the characters may include digits and the underscore character. You may not use periods in the name other than the last one in ’.m’ and the name cannot contain blank spaces.
  • 25. • Avoid name clashes with built-in functions. It is a good idea to first check if a function or a script file of the proposed name already exists. You can do this with the command exist(’name’), which returns zero if nothing with name name exists. • NEVER name a script file or function file the same as the name of the variable it computes. When MATLAB looks for a name, it first searches the list of variables in the workspace. If a variable of the same name as the script file exists, MATLAB will never be able to access the script file. c⃝2011 Stefania Tracogna, SoMSS, ASU MATLAB sessions: Laboratory 1 Exercises Instructions: You will need to record the results of your MATLAB session to generate your lab report. Create a directory (folder) on your computer to save your MATLAB work in. Then use the Current Directory field in the desktop toolbar to change the directory to this folder. Now type diary lab1 yourname.txt followed by the Enter key. Now each computation you make in MATLAB will be save in your directory in a text file named lab1 yourname.txt. When you have finished
  • 26. your MATLAB session you can turn off the recording by typing diary off at the MATLAB prompt. You can then edit this file using your favorite text editor (e.g. MS Word). Lab Write-up: Now that your diary file is open, enter the command format compact (so that when you print out your diary file it will not have unnecessary blank lines), and the comment line % MAT 275 MATLAB Assignment # 1 Include labels to mark the beginning of your work on each part of each question, so that your edited lab write-up has the format % Exercise 1 . . % Exercise 2 Final Editing of Lab Write-up: After you have worked through all the parts of the lab assignment you will need to edit your diary file. • Remove all typing errors. • Unless otherwise specified, your write-up should contain the MATLAB input commands, the corresponding output, and the answers to the questions that you have written. • If the exercise asks you to write an M-file, copy and paste the
  • 27. file into your diary file in the appropriate position (after the problem number and before the output generated by the file). • If the exercise asks for a graph, copy the figure and paste it into your diary file in the appropriate position. Crop and resize the figure so that it does not take too much space. Use “;” to suppress the output from the vectors used to generate the graph. Make sure you use enough points for your graphs so that the resulting curves are nice and smooth. • Clearly separate all exercises. The exercises’ numbers should be in a larger format and in boldface. Preview the document before printing and remove unnecessary page breaks and blank spaces. • Put your name and class time on each page. Important: An unedited diary file without comments submitted as a lab write-up is not acceptable. 1. All points with coordinates x = r cos(θ) and y = r sin(θ), where r is a constant, lie on a circle with radius r, i.e. satisfy the equation x2 + y2 = r2. Create a row vector for θ with the values 0, π 4 , π 2 , 3π 4 , π, and 5π
  • 28. 4 . Take r = 2 and compute the row vectors x and y. Now check that x and y indeed satisfy the equation of a circle, by computing the radius r = √ x2 + y2. Hint: To calculate r you will need the array operator .^ for squaring x and y. Of course, you could also compute x2 by x.*x. c⃝2011 Stefania Tracogna, SoMSS, ASU MATLAB sessions: Laboratory 1 2. Use the linspace command or the colon operator : to create a vector t with 91 elements: 1, 1.1, 1.2, . . . , 10 and define the function y = et/10 sin(t) t2 + 1 (make sure you use “;” to suppress the output for both t and y). (a) Plot the function y in black and include a title with the expression for y. (b) Make the same plot as in part (a), but rather than displaying
  • 29. the graph as a curve, show the unconnected data points. To display the data points with small circles, use plot(t,y,’o’). Now combine the two plots with the command plot(t,y,’o-’) to show the line through the data points as well as the distinct data points. 3. Use the command plot3(x,y,z) to plot the circular helix x(t) = sin t, y(t) = cos t, z(t) = t 0 ≤ t ≤ 20. NOTE: Use semicolon to suppress the output when you define the vectors t, x, y and z. Make sure you use enough points for your graph so that the resulting curve is nice and smooth. 4. Plot y = cos x in red with a solid line and z = 1 − x 2 2 + x 4 24 in blue with a dashed line for 0 ≤ x ≤ π on the same plot. Hint: Use plot(x,y,’r’,x,z,’--’). Add a grid to the plot using the command grid on. NOTE: Use semicolon to suppress the output when you define the vectors x, y and z. Make sure you use enough points for your graph so that the resulting curves are nice and smooth. 5. The general solution to the differential equation dy
  • 30. dx = x + 2 is y(x) = x2 2 + 2x + C with y(0) = C. The goal of this exercise is to write a function file to plot the solutions to the differential equation in the interval 0 ≤ x ≤ 4, with initial conditions y(0) = −1, 0, 1. The function file should have the structure function+function (similarly to the M-file myplot1.m Example 3, page 5). The function that defines y(x) must be included in the same file (note that the function defining y(x) will have two input arguments: x and C). Your M-file should have the following structure (fill in all the ?? with the appropriate commands): function ex5 x = ?? ; % define the vector x in the interval [0,4] y1 = f(??); % compute the solution with C = -1 y2 = f(??); % compute the solution with C = 0 y3 = f(??); % compute the solution with C = 1 plot(??) % plot the three solutions with different line-styles title(??) % add a title
  • 31. legend(??) % add a legend end function y = f(x,C) y = ?? % fill-in with the expression for the general solution end Plot the graphs in the same window and use different line-styles for each graph. To plot the graphs in the same window you can use the command hold on or use the plot command similarly to Exercise 4. Add the title ’ Solution s to dy/dx = x + 2’. Add a legend on the top left corner of the plot with the list of C values used for each graph. c⃝2011 Stefania Tracogna, SoMSS, ASU MATLAB sessions: Laboratory 1
  • 32. (Type help plot for a list of the different line-styles, and help legend for help on how to add a legend.) Include both the M-file and the plot in your report. NOTE: the only output of the function file should be the graph of the three curves. Make sure you use enough points so that the curves are nice and smooth. 6. (a) Enter the function f(x, y) = x3 + yex x + 1 as an inline or anonymous function (see page 6). Evaluate the function at x = 2 and y = −1. (b) Type clear f to clear the value of the function from part (a). Now write a function M-file for the function f(x, y) = x3 + yex x + 1 . Save the file as f.m (include the M-file in your report). Evaluate the function at x = 2 and y = −1 by entering f(2,-1) in the command window.