0% found this document useful (0 votes)
58 views11 pages

Lab Report: Lab 01 (MATLAB Overview) : Student ID: 170021031 Name: Md. Tawsif Mostafiz Section: A Group: A1

This lab report summarizes MATLAB assignments completed by the student. The assignments included: generating matrices with incrementing elements; replacing a matrix row and extracting a submatrix to find its inverse; plotting sine waves using Euler's identity with frequencies based on the student ID; cumulatively summing sine waves in a loop; using a function to calculate factorials; counting positive values in a sine wave; generating square and sawtooth waves. Code and output are provided for each assignment.

Uploaded by

Tawsif Mostafiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
58 views11 pages

Lab Report: Lab 01 (MATLAB Overview) : Student ID: 170021031 Name: Md. Tawsif Mostafiz Section: A Group: A1

This lab report summarizes MATLAB assignments completed by the student. The assignments included: generating matrices with incrementing elements; replacing a matrix row and extracting a submatrix to find its inverse; plotting sine waves using Euler's identity with frequencies based on the student ID; cumulatively summing sine waves in a loop; using a function to calculate factorials; counting positive values in a sine wave; generating square and sawtooth waves. Code and output are provided for each assignment.

Uploaded by

Tawsif Mostafiz
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Lab Report: Lab 01 (MATLAB Overview)

Student ID: 170021031


Name: Md. Tawsif Mostafiz
Section: A
Group: A1
Assignment
• Generate a matrix of dimension 10 x 10 having elements increment first row wise then
column wise starting from zero.
Row wise:
Code:

for i= 1:10;
for j= 0:9;
A(i,j+1)= j;
end
end
disp(A)

Output:
Column wise:
Code:
for i= 1:10;
for j= 0:9;
A(j+1,i)= j;
end
end
disp(A)

Output:
• Generate a 5 x 5 Matrix and replace its 3rd row with values between 0 and 1. Then
extract any 2 x 2 sub-matrix out of that parent matrix and find out the inverse of the
sub-matrix.
Description: As type of the matrix is not given, I have used a magic square.
Code:
x=magic(5);
disp('The matrix is:');
disp(x);
i=3;
for j= 1:5;
x(i,j)= rand;

end

disp('The matrix with replaced value:' );


disp(x);

z= x([2:3],[2:3]);

disp('The 2*2 matrix');


disp(z);

disp('Inverse of the 2*2 matrix');


disp(inv(z));

Output:
• Generate sine wave using the Eider's identity. The frequency of that sine wave will be
equal to the last two digits of your student number. Plot the wave for 0 to 2 second
having .005 second interval.
Description: At .005 second interval, the total number of value is 400.
Code:

t=linspace(0,2,400);
y = (exp(i*2*pi*31*t)-exp(-i*2*pi*31*t))/2*i;
plot(x,y)

Output:
• For students with odd last three digits of student number: Plot cumulatively summed
sine waves with odd integer frequencies starting from (last three digits of your student
number) Hz to (last three digits of your student number+8) Hz. Use for loop for the
summation and show each step of the summation using subplot command.
Description: ID is 031
Code:
t = 0:.01:1;
sum=0;

A = 8;
for f= 31:2:31+8;
y=A*sin(2*pi*f*t);
z=sum+y;
end
plot(t,z)
title('Addition')
ylabel('Amplitude')

Output:
• Using function operator, write a MATLAB code which will calculate the factorial of any
positive number.
Code:
number = input('Enter Number: ')
disp(' Factorial is');
disp(factorial(number))

Output:

• Given x= sin(linspace(0,10*pi,100)), write a MATLAB code which will count the number
of positive values.
Code:

x=sin(linspace(0,10*pi,100));
positive = find(x>0);
length(positive)

Output:
• Write the MATLAB code to generate a Square wave of amplitude 5 volts, fundamental
frequency 20 Hz and duty cycle 0.6.
Code:

t=0:.001:.5;
f=20;
A=5;
duty=.6;
x=A*(square(2*pi*f*t,duty));
plot(t,x)
ylim([-7 7])

Output:
• Write the MATLAB code to generate a Sawtooth wave of amplitude of 5 volts and
fundamental frequency 20 Hz.
Code:

t=0:.001:.5;
f=20;
A=5;
x=A*(sawtooth(2*pi*f*t,0.6));
plot(t,x)

Output:
• Generate the following signals in MATLAB:
1st Signal:
Code:

A=1;
w=.5;
f=.335;
t=-.75:.01:6;
triangular=A*sawtooth((2*pi*f*t),w);

plot(t+.738239,triangular)
xlim([0 3]);

Output:
2nd Signal

Code:
A=1;
period=10*pi;
w=.75;
f=.17;
t=0:.01:6;

triangular=A*sawtooth((2*pi*f*t),w);

plot(t-2.2,triangular)
xlim([-1 4]);
ylim([0 1]);

Output:

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy