4 (A) Given Below A MATLAB Program To Find The Integration of

You might also like

Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 5

4(a) Given below a MATLAB program to find the integration of

using trapezoidal rule. Comment beside each line what do you


understand?
10 marks

n=5;
a=0;
b=1;
h=(b-a)/n;
m=0.5*(ft(a)+ft(b));

s=0;
for i=1:1:n-1
s=s+ft(a+i*h);
end
r=h*(m+s);

4(b). Like the trapezoidal rule, another numerical integration formula is


Simpsons rule.
Where,
n=
number of sub intervals
I= result
of Integration
Assume n=1000. write a MATLAB program to find the integration of
10 marks

5. If

dy
=0.4 y0.1 x 2 and y(2)=3 write down a MATLAB program to find
dt

the solution for y using Eulers method. Take step size 0.005 and
0 x 5

10marks

1. A) Why sequence of commands are written in script file instead of command


window.
2 marks

B) Between function file and script file which file you can execute?
What are the similarities between them?
4 marks

C) Following is an experimental datasheet of your fluid lab.


v

Q=Av

Re=Ro*v*d/mi
u

f=64/R
e

5
6
1
0
1
2
1
4
Usually you submit the data sheet with the report by calculating each
individual cell of each column by calculator. Now, by using MATLAB
you can easily do the same task if you know some basic vector
operations. Using vectors write the commands in MATLAB, to calculate
each column
N.B. no need to show calculation, just write the vector operation for each
column.
Assume miu=1e-3, A=0.054, d=0.03, Ro=1000.
4 marks

D) let p is a vactor
P=[ 4 5 6 7 8];
Write a MATLAB program, that will give the sum of all the elements in
this vector.
5 marks

E)The perimeter P of an ellipse with semi-minor axes a and b is given


approximately by
a
1
2
P=2 2 ( 2+b )

An ellipse with has a perimeter of P = 60 cm. write the proper MATLAB code
using subs function Determine a and b. relation between a and b is b=3a.
OR
Two matrices are given below. Assign them to two variables as shown. Then Write
a matlab code to perform elementwise multiplication and matrix multiplication
between them. Write a difference between vector and matrix in MATLAB
5 marks

You might also like