More instructions for the lab write-up1) You are not obli.docxgilpinleeanna
More instructions for the lab write-up:
1) You are not obligated to use the 'diary' function. It was presented only for you convenience. You
should be copying and pasting your code, plots, and results into some sort of "Word" type editor that
will allow you to import graphs and such. Make sure you always include the commands to generate
what is been asked and include the outputs (from command window and plots), unless the problem
says to suppress it.
2) Edit this document: there should be no code or MATLAB commands that do not pertain to the
exercises you are presenting in your final submission. For each exercise, only the relevant code that
performs the task should be included. Do not include error messages. So once you have determined
either the command line instructions or the appropriate script file that will perform the task you are
given for the exercise, you should only include that and the associated output. Copy/paste these into
your final submission document followed by the output (including plots) that these MATLAB
instructions generate.
3) All code, output and plots for an exercise are to be grouped together. Do not put them in appendix, at
the end of the writeup, etc. In particular, put any mfiles you write BEFORE you first call them.
Each exercise, as well as the part of the exercises, is to be clearly demarked. Do not blend them all
together into some sort of composition style paper, complimentary to this: do NOT double space.
You can have spacing that makes your lab report look nice, but do not double space sections of text
as you would in a literature paper.
4) You can suppress much of the MATLAB output. If you need to create a vector, "x = 0:0.1:10" for
example, for use, there is no need to include this as output in your writeup. Just make sure you
include whatever result you are asked to show. Plots also do not have to be a full, or even half page.
They just have to be large enough that the relevant structure can be seen.
5) Before you put down any code, plots, etc. answer whatever questions that the exercise asks first.
You will follow this with the results of your work that support your answer.
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: ...
MATLAB retains your previous keystrokes.
• Use the up-arrow key to scroll back back through the commands.
• Press the key once to see the previous entry, and so on.
• Use the down-arrow key to scroll forward. Edit a line using the left- and right-arrow keys the Backspace key, and the Delete key.
• Press the Enter key to execute the command.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
More instructions for the lab write-up1) You are not obli.docxgilpinleeanna
More instructions for the lab write-up:
1) You are not obligated to use the 'diary' function. It was presented only for you convenience. You
should be copying and pasting your code, plots, and results into some sort of "Word" type editor that
will allow you to import graphs and such. Make sure you always include the commands to generate
what is been asked and include the outputs (from command window and plots), unless the problem
says to suppress it.
2) Edit this document: there should be no code or MATLAB commands that do not pertain to the
exercises you are presenting in your final submission. For each exercise, only the relevant code that
performs the task should be included. Do not include error messages. So once you have determined
either the command line instructions or the appropriate script file that will perform the task you are
given for the exercise, you should only include that and the associated output. Copy/paste these into
your final submission document followed by the output (including plots) that these MATLAB
instructions generate.
3) All code, output and plots for an exercise are to be grouped together. Do not put them in appendix, at
the end of the writeup, etc. In particular, put any mfiles you write BEFORE you first call them.
Each exercise, as well as the part of the exercises, is to be clearly demarked. Do not blend them all
together into some sort of composition style paper, complimentary to this: do NOT double space.
You can have spacing that makes your lab report look nice, but do not double space sections of text
as you would in a literature paper.
4) You can suppress much of the MATLAB output. If you need to create a vector, "x = 0:0.1:10" for
example, for use, there is no need to include this as output in your writeup. Just make sure you
include whatever result you are asked to show. Plots also do not have to be a full, or even half page.
They just have to be large enough that the relevant structure can be seen.
5) Before you put down any code, plots, etc. answer whatever questions that the exercise asks first.
You will follow this with the results of your work that support your answer.
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: ...
MATLAB retains your previous keystrokes.
• Use the up-arrow key to scroll back back through the commands.
• Press the key once to see the previous entry, and so on.
• Use the down-arrow key to scroll forward. Edit a line using the left- and right-arrow keys the Backspace key, and the Delete key.
• Press the Enter key to execute the command.
Final project report on grocery store management system..pdfKamal Acharya
In today’s fast-changing business environment, it’s extremely important to be able to respond to client needs in the most effective and timely manner. If your customers wish to see your business online and have instant access to your products or services.
Online Grocery Store is an e-commerce website, which retails various grocery products. This project allows viewing various products available enables registered users to purchase desired products instantly using Paytm, UPI payment processor (Instant Pay) and also can place order by using Cash on Delivery (Pay Later) option. This project provides an easy access to Administrators and Managers to view orders placed using Pay Later and Instant Pay options.
In order to develop an e-commerce website, a number of Technologies must be studied and understood. These include multi-tiered architecture, server and client-side scripting techniques, implementation technologies, programming language (such as PHP, HTML, CSS, JavaScript) and MySQL relational databases. This is a project with the objective to develop a basic website where a consumer is provided with a shopping cart website and also to know about the technologies used to develop such a website.
This document will discuss each of the underlying technologies to create and implement an e- commerce website.
Sachpazis:Terzaghi Bearing Capacity Estimation in simple terms with Calculati...Dr.Costas Sachpazis
Terzaghi's soil bearing capacity theory, developed by Karl Terzaghi, is a fundamental principle in geotechnical engineering used to determine the bearing capacity of shallow foundations. This theory provides a method to calculate the ultimate bearing capacity of soil, which is the maximum load per unit area that the soil can support without undergoing shear failure. The Calculation HTML Code included.
Student information management system project report ii.pdfKamal Acharya
Our project explains about the student management. This project mainly explains the various actions related to student details. This project shows some ease in adding, editing and deleting the student details. It also provides a less time consuming process for viewing, adding, editing and deleting the marks of the students.
CFD Simulation of By-pass Flow in a HRSG module by R&R Consult.pptxR&R Consult
CFD analysis is incredibly effective at solving mysteries and improving the performance of complex systems!
Here's a great example: At a large natural gas-fired power plant, where they use waste heat to generate steam and energy, they were puzzled that their boiler wasn't producing as much steam as expected.
R&R and Tetra Engineering Group Inc. were asked to solve the issue with reduced steam production.
An inspection had shown that a significant amount of hot flue gas was bypassing the boiler tubes, where the heat was supposed to be transferred.
R&R Consult conducted a CFD analysis, which revealed that 6.3% of the flue gas was bypassing the boiler tubes without transferring heat. The analysis also showed that the flue gas was instead being directed along the sides of the boiler and between the modules that were supposed to capture the heat. This was the cause of the reduced performance.
Based on our results, Tetra Engineering installed covering plates to reduce the bypass flow. This improved the boiler's performance and increased electricity production.
It is always satisfying when we can help solve complex challenges like this. Do your systems also need a check-up or optimization? Give us a call!
Work done in cooperation with James Malloy and David Moelling from Tetra Engineering.
More examples of our work https://www.r-r-consult.dk/en/cases-en/
2. 2
Objectives
Background of MATLAB
Advantages and disadvantages
Applications
Basic commands, syntax
Introduction to decimal places, rounding, significant figures
Solve problems using different mathematical methods
3. 3
Background of MATLAB
It stands for matrix laboratory
It is a technical programming language
Superior to other language such as C, FORTRAN
A special purpose of computer program optimized to perform
engineering and scientific calculations
It provides very extensive library of predefined functions to
make technical programming task easier and efficient.
4. 4
Advantages and Disadvantages of MATLAB
Advantages:
Easy to use
Independent platform
Pre-defined functions
Device independent plotting
Graphical user interface
Disadvantages:
Computing speed is slow
Cost effective for business
5. 5
Applications
Technical computing
Control design
Communications design
Test and Measurement
Image processing
Signal processing
Chemical Industry
Financial modelling and Analysis
6. 6
Basic commands and Syntax
Simple computation may be carried out in the Command Window
by entering an instruction at the prompt. Commands and names are
case sensitive.
# Used fixed constant (Example-pi())
# Built-in Functions
Mathematical functions are available with commonly used name.
Note the following change:
log() natural logarithm(ln), log10() log base 10
Percent (%) sign is used to write comments.
Semicolon (;) at the end of command suppress the output.
# Matrices
All variables in MATLAB are treated as matrices or arrays.
A row vector may be entered as
>> x=[1 2 3] or x=[1,2,3]
Output x =
1 2 3
7. 7
A column vector may be entered as
>> y = [4; 5; 6] or y = [4 5 6]’
Output y =
4
5
6
# Semicolons are used to separate the rows of a matrix.
An example of a 3-by-4 matrix is B = [1 2 3 4; 5 6 7 8; 9 10 11 12]
# Using colon (:)
Example- x=1:5 %Generates a vector with interval of 1 from
1 to ≤ 5
# Use linspace
Example-linspace (a, b, n) % generate n values in [a, b] with
equal length
x2 = linspace(1,2.5,4)
Output x2 =
1 1.5 2 2.5
8. 8
Controlling number of digits
The fixed-point numbers:
format short displays 5 digits
format long displays 16 digits
The floating-point representation:
format short e gives 5 digits plus the exponent
format long e gives 16 digits plus the exponent
The combined format (fixed point or floating depending on the
magnitude of the number)
format short g
format long g
9. 9
Printing command in MATLAB
1. By typing the name of a variable (displays the output indicating
variable name).
Example- write the new script then save as “.m” file.
clear
>>A=[1, 2.25 4.56];
>> A
A =
1.0000 2.2500 4.5600
2. By using “disp” built in function. This displays output without
variable name.
>>disp(A)
1.0000 2.2500 4.5600
3. By using “fprintf “ function
Syntax: fprintf(formatSpec, A1, A2, . . . , A3)
11. 11
Plotting command in MATLAB
7cos 2 1
y x x
2-D Plot
plot(y) x = 1 : n (if not supplied)
plot(x,y) x, y are vectors
plot(x1, y1, . . .. , xn,Yn)
title(‘plot title’) grid on grid off
xlabel(‘label for x-axis’) grid (toggles)
ylabel(‘label for y-axis’) hold on hold off
box on
Example #. Plot the function in [-4,4].
>> x= -4:0.2:4;
>> y=7*cos(x)+2*x-1;
>> plot(x,y);grid on
12. 12
Plotting command in MATLAB
3-D Plot
plot3(x,y,z) % Command
Example #. Plot the function
>> x=linspace(-5,5,50);
>> y=x;
>> z=4-x.^2-y.^2;
>> plot3(x,y,z); grid on;
2 2
4
z x y
Construction of Functions in the Command Window
1. Inline function
f1 =jnline(expr)
f2=inline(expr, arg1, arg2,. . . )
Example
>> f=inline('x^2+2*x*y')
f =
Inline function:
f(x,y) = x^2+2*x*y
>> v1=f(1, 2.2)
Result
v1 =
5.4000
13. 13
Construction of Functions in the Command Window
2. Function_handle (@) )
handle=@(arglist) anonymous_function
Example
>> ff=@(x,y) x.^2+x./y
ff =
@(x,y)x.^2+x./y
>> ff(1.1,2)
ans =
1.7600
3. Function using Symbols
>> syms x y
>> ff(x,y)=x.^2+x./y
ff(x, y) =
x^2 + x/y
To compute elementwise in array use
POWER with (.^) , DIVISION with (./) and PTRODUCT with (.*)
>> ff(1.2, 2) % returns result in fracttion
ans =
51/25
>> ffval=eval(ff(1.2,2)) % eval( ) is used to convert fraction
to decimal form
ffval =
2.04
14. 14
m-Files
There are two types of programs (m-files) in MATLAB: Functions
and Scripts.
User Defined Functions
To be created in function window.
To open: New Function
To save: Save enter file name and save
To run: Type function name in command window
To edit: Open select the file from the list and
edit. save again
function t=FF(a)
t=7*cos(a)+2*a-1;
end
15. 15
m-Files
The function which is created as an m-file and saved as FF.m.
To use the above function type in command window.
>> t=FF(2)
t =
0.0870
Scripts
Scripts provide a set of MATLAB commands, comments, values,
plotting commands, and so on.
A scripts that has been created and saved is executed by typing the file
name at the MATLAB prompt in the command window or using save and
run from the Debug menu.
To open: New Script
To save: Save enter file name and save
To run: Type script name in command window
To edit: Open select the file from the list and edit. Save again
16. 16
Scripts
% Script TestProgm
%Values of f(x) for different values of x
x= x0;
disp('n xn f(xn)')
for i=1:nmax
fx=f(x);
n=i-1;
disp([n,x,fx])
x=x+h;
end
Save the script as TestProg.m
To execute the script from Command Window,
type following commands:
>> clear
>> x0=1;
>> h=0.5;
>> f=inline('7.*cos(x)+2.*x-1')
f =
Inline function:
f(x) = 7*cos(x)+2*x-1
>> nmax=5
nmax =
5
>> TestProg % Type the Script name
Output
n xn f(xn)
0 1.0000 4.7821
1.0000 1.5000 2.4952
2.0000 2.0000 0.0870
3.0000 2.5000 -1.6080
4.0000 3.0000 -1.9299
17. 17
Programming in MATLAB
Normally in a programming language, it is necessary to specify type of variable used in
the program (integer, real, complex, and so on). MATLAB treats all variables as matrices
(whatever dimension is needed) and perform the necessary calculations.
To repeat similar calculations several times for and while loops are used. Syntax are
While Loops
while statement == true
commands . . .
end
For Loops
for i = 1 : k
commands . . .
end
Example #: Write MATLAB codes for calculating n! using for loop.
>> clear
>> n=input('please input number = ');
fact=1;
i=1;
for i=1:n
fact=fact*i;
i=i+1;
end
disp(fact)
Outcome:
please input number = 5
120
18. 18
Conditional execution can be indicated by if
statement.
if expression
commands . . .
end
The break command causes MATLAB to jump outside the loop in which it occurs.
The error command abort function execution , displays a character string in the command
Window, and returns control to the keyboard.
If there are more alternatives, the form is
if expression1
commands . . .
elseif expression2
commands . . .
elseif …
. . .
end
Break and Error
MATLAB contributes to solve in numerous common mathematical areas such as calculus,
linear algebra, algebraic equations differential equations and so on. MATLAB also provides
symbolic calculations and manipulations symbolic mathematical expression. For this
purpose we need to define the symbols and it can be done by using the MatLab default
command ‘syms ’.
Computer Algebra System (CAS) with MATLAB
19. 19
Solve problems using Basic commands and Syntax
Example #: Solve the equation 𝑥2 − 5𝑥 + 𝑎 = 0, whether a is a constant.
MATLAB codes are
>>syms x a
>> Solution=solve(x.^2-5.*x+a= = 0,x) % solve(eqn, var) is to solve an equation
Solution=
5/2 - (25 - 4*a)^(1/2)/2
(25 - 4*a)^(1/2)/2 + 5/2
Example #: Find the general solution of differential equation
𝑦′′
+ 3𝑦′
+ 2𝑦 = 𝑒−𝑥
.
>> clear
>> syms y(x)
>> Dy=diff(y);
>> D2y=diff(y,2);
>> GS=dsolve(D2y+3*Dy+2*y==exp(-x)) % dsolve(eqn) solves D.E.
GS =
x*exp(-x) - exp(-x) + C3*exp(-x) + C4*exp(-2*x)
20. 20
Representation of Numbers in MATLAB
Percentage of error = Relative error 100 %
Decimal places (d.p.):
The number of digits counted after the decimal marker.
Significant figures (s.f.):
All digits including zero are counted from the first non-zero digit.
Rounding:
The last retained digit is corrected up if the succeeding digit is
greater than or equal to 5, otherwise chopped off.
Error Measurement
Numerical calculations can be in error due to the use of approximate values in
the calculation. The following definitions are used in measuring the errors.
Absolute error =True value Approximate value
value
True
value
Approx.
value
True
value
True
error
Absolute
Relative error=
21. 21
%
100
ion
approximat
Current
on
appoximati
Previous
ion
approximat
Current
a
can be estimated by using the relation
,
a
Note that in absence of true value an approximate relative error,
3
2
1 10
0005
.
0
Rounding Error
If 2.326 is a number rounded to 3 d.p., the true value is
2.3255 2.3265or 2.326 0.0005
n
10
2
1
Thus the maximum absolute error is
If a number is rounded to n decimal places, the maximum absolute error is
22. 22
Consider two numbers 235.3 and 0.003267 which are rounded to 4 s.f.. The
errors can be estimated as follows
For 235.3, the relative error is 3
2
1
3
2
1
2
1
2
1
10
353
.
2
10
10
353
.
2
10
For 0.003267. the relative error is 3
2
1
3
2
1
3
6
2
1
10
267
.
3
10
10
267
.
3
10
In general, if a number is rounded to n significant figures the maximum
relative error is 1
1
2 10 .
n
The table below shows various errors corresponding to the given true and
approximate values.
True value Approximate
value
Absolute
error
Relative
error
Percentage
error
3.141592 3.142 0.00041 0.00013 0.013
100000 99950 50 0.0005 0.05
0.00025 0.0003 0.00005 0.2 20
23. 23
Solve problems using Basic commands and Syntax
Example #: 0
2
c
bx
ax
The solution of the quadratic equation
is )
2
(
)
4
( /
2
a
ac
b
b
x
Write a MATLAB script to solve the quadratic equation with variable coefficients
which gives variable significant digits.
Solution:
% Script QuadEq for solution
clear all
disp('Solution of Quadratic Equation')
% Equation : ax^2+bx+c=0
% Roots: x1= -b+sqrt(b^2-4ac)/(2a)
% x2= -b-sqrt(b^2-4ac)/(2a)
abc=input('Supply a,b,c as [a,b,c]=');
a=abc(1); b=abc(2); c=abc(3);
x1=(-b+sqrt(b^2-4*a*c))/(2*a);
x2=(-b-sqrt(b^2-4*a*c))/(2*a);
Roots=[x1,x2]
disp('Roots to n significant digits')
n=input('Value of n = ');
Roots_n=vpa([x1; x2],n)
24. 24
Try to do yourself
Outcomes
Numerically solve problems by using different mathematical
methods, built in function in MATLAB
Visualization problems by data analysis
Save time for solve problems
Exercise 1:Write script and solve the following equation then correct
it to ten significant figures.
2
6 9886 1 0
x x
𝑦′′
− 2𝑦′
+ 10𝑦 = 5𝑥 − 𝑒3𝑥
Exercise 2:Find the general solution of the following ordinary
differential equation (ODE)
25. 25
Calculate the Celsius temperature by using the following relation
between 𝐹 and 𝐶
Exercise 3:
𝐹 − 32
180
=
𝐶
100
where the range of Fahrenheit temperatures from 10 to 200 with interval 5.
Then print these values with the proper headings by using the “fprintf” command
in MATLAB.
References
Text Book:
Applied Numerical Methods with MATLAB for Engineers and Scientists- S.C. Chapra,
4th Edition, 2017, McGraw Hill-Europe.
Reference Book:
Numerical Methods in Engineering with MATLAB – Jaan Kiusalaas, 4th Edition, 2018,
CAMBRIDGE UNIVERSITY PRESS, UK.
Applied Numerical Methods With Matlab for Engineers and Scientists ( Steven
C.Chapra).