Professional Documents
Culture Documents
Matlab Code:-
clc
clear
close
t=-4*pi:pi/10:4*pi %defining range of x-axis
f=0.1 %setting the value of frequency
y=sin(2*pi*f*t) %defining sin function
plot(t,y,'r--') %plotting the function
text(0,1,'Max Value','fontsize',10,'color','magenta') %setting text on given
coordinate
title('sine graph') % setting title
Output:-
Criteria Total Marks Marks Obtained Comments
Concept(A) 2
Implementation(B) 2
Performance(C) 2
Total 6(To be scaled down to
1)
Experiment 7:- : Solving First, Second and third Order Ordinary Differential Equation using Built-in
Functions and plot.
Matlab Code:-
(a)
Clc
Clear
close
syms y(t) a %symbolically defining variables
p=diff(y,t)==a*y %first order differential equation
dsolve(p) %solving the differential equation
Output:-
(b)
clc
clear
close
syms y(t) a %symbolically defining variables
p=diff(y,t,2)==a*y %3rd order differential equation
q=diff(y,t) %defining 1st order differential equation
cond=[y(0)==1 q(0)==2] %defining given conditions
dsolve(p,cond) %solving the differential equation
Output:-
Criteria Total Marks Marks Obtained Comments
Concept(A) 2
Implementation(B) 2
Performance(C) 2
Total 6(To be scaled down to
1)
Experiment 8
Writing brief Scripts starting each Script with a request for input (using input) to Evaluate the function
h(T) using if-else statement, where, o h(T) = (T – 10) for 0 < T < 100 = (0.45 T + 900) for T > 100.
Exercise: Testing the Scripts written using A). T = 5, h = -5 and B). T = 110, h =949.5
Code:-
H=T-10;
disp(H);
elseif(T>100)
H=0.45*T+900;
disp(H);
else
end
Output:-
Criteria Total Marks Marks Obtained Comments
Concept(A) 2
Implementation(B) 2
Performance(C) 2
Total 6(To be scaled down to
1)
Experiment 9
Aim:- Generating a Square Wave from sum of Sine Waves of certain Amplitude and Frequencies.
Theory:
*For loop
Syntax
Sum=0
For i=1:5
Sum=sum+i;
End
*sin function
Y=sin(x);
X is in radians
*Square Wave is a waveform in which the amplitude alternates at a steady frequency between fixed
minimum and maximum values.
Code:-
f = 5;
w = 2*pi*f;
t = 0:0.0001:1
y = 0;
for n = 1:2:99;
y = y + (1/n)*sin (n*w*t);
end
subplot(2,2,1)
plot(t,y, 'r--');
xlabel('Time axis');
ylabel('Amplitude');
legend('Squarewave');
title('squarewave continous');
subplot(2,2,2)
stem(t,y, 'o--');
xlabel('Time axis');
ylabel('Amplitude');
legend('squarewave');
title('squarewave discret');
Output:-
Criteria Total Marks Marks Obtained Comments
Concept(A) 2
Implementation(B) 2
Performance(C) 2
Total 6(To be scaled down to
1)
Experiment 10:
Aim:- Basic 2D and 3D plots: parametric space curve. polygons with vertices. 3D contour lines,
pie and bar charts.
Software Used:- Matlab 2019.
Code:-
clc
clear
close
t = 0:pi/50:10*pi;
st = sin(t);
ct = cos(t);
subplot(3,2,1)
plot3(st,ct,t)
x = 0:pi/10:2*pi;
y = sin(x);
subplot(3,2,2)
pie(x,y)
subplot(3,2,3)
pie3(x,y)
subplot(3,2,4)
bar(x,y)
subplot(3,2,5)
bar3(x,y)
Output:-
Criteria Total Marks Marks Obtained Comments
Concept(A) 2
Implementation(B) 2
Performance(C) 2
Total 6(To be scaled down to
1)
Open Ended Experiment
Basic Simulation Lab
Harshit Aggarwal
A2305218044
4CSE1Y
Submitted to:-
Mr. Yogesh
OPEN ENDED EXPERIMENT
Aim: To covert coloured image to grayscale and then to black and white.
Software Used: MATLAB R2019b
Theory:
RGB = RGB('COLORNAME') returns the red-green-blue triple
corresponding to the color named COLORNAME by the CSS3 proposed
standard [1], which contains 139 different colors (an rgb triple is a 1x3 vector of
numbers between 0 and 1). The color names are the ones accepted by almost all
web browsers, for example Brown, DarkRed, SlateGray.
RGB CHART creates a figure window showing all the available colors with
their names.
Output:-