Need Help with MATLAB Project? We’ve Got You CoveredWe, at Matlab Assignment Experts, clearly understand that getting started and perfectly tackling your Matlab project does not come easily. That’s why we are here for you; we will not only aid you with your project but also offer tutoring services t...
clear all,clc
% tests:
B1=[1 -0.8];
A1=[1 1.5 0.9];
Ts=1;
% System is table in z if all poles lie inside a circle of unit 1
p=roots(A1);
if(abs(p)<=1),
disp(['Z domain system is stable']);
else disp(['Z domain system is Not stable'])
end
% For Time domain we will convert form d2c
sys=d2c(tf(B1,A1,Ts));
[numc,denc]=tfdata(sys,'v');
pc=roots(denc);
if real(pc)<0
disp(['Time Domain system is stable']);
else
disp(['Time Domain system is not stable']);
end
% zero-state response vs. zero-input response
BB=[2.24 2.49 2.24];
AA=[1 -0.4 0.75];
n=-2:1:20;
% The filter will be used for the following initial conditions
x=(n>=0);
b1=2.24; b2=2.49; b3=2.24;
a1=1; a2=-0.4; a3=0.75;
zi2=[-2*a1-1*a2,b1*0-a2*2];
y=filter(BB,AA,x,zi2);
stem(n,y); grid on
title('The response with initial condition of 2nd order system')
% area.m
% computes the area and perimeter of a rectangle
% Asks for the length of the rectangle
L = input( ' What is the length of the rectangle ? ' );
% Asks for the width of the rectangle
W = input( ' What is the width of the rectangle ? ' );
% computes the area and perimeter
Area = L * W ;
Perimeter = 2*(L + W);
% displays the area and perimeter
fprintf('The area of the rectangle is: %g \n', Area)
fprintf('The perimeter of the rectangle is: %g \n', Perimeter)
% avg.m
% computes the average value of three numbers
% Asks for the three numbers whose average is to be found
N1 = input( ' What is the first number, N1 ? ' );
N2 = input( ' What is the second number, N2 ? ' );
N3 = input( ' What is the third number, N3 ? ' );
% computes the average value of the three numbers
AverageN = (N1 + N2 + N3)/3 ;
% displays the average value of the three numbers
fprintf('The average of the three numbers is: %g \n', AverageN)
% circle.m
% finds the area of a circle with a known diameter
% Asks for diameter of the circle
d = input( ' What is the diameter of the circle ? ' );
% Find the area of a circle
Area = pi * d^2 /4 ;
% displays the area and perimeter
fprintf('The area of the circle is: %g \n', Area)
% polynom
% solves for the roots of a 2nd order polynomial equation using quadratic
% formula
% asks for the values of a, b and c
a = input('What is the value of a ?');
b = input('What is the value of b ?');
c = input('What is the value of c ?');
% computes the roots s1 and s2
s1 = (-b + sqrt(b^2 - 4*a*c))/(2*a);
s2 = (-b - sqrt(b^2 - 4*a*c))/(2*a);
% displays the roots s1 and s2
fprintf('The roots of the polynomial are: s1 = %g and s2 = %g \n', s1,s2)
% rctime.m
% computes the charging voltage for a resistor and capacitor circuit
% asks for the values of Vcc, tmax, R and C
Vcc = input('What is the value of Vcc ?');
R = input('What is the resistor value, R ?');
C = input('What is the capacitor value, C ?');
tmax = input('What is the maximum time for evaluation, tmax ?');
t = linspace(0,tmax,100);
% computes V
V = Vcc*(1- exp(-t/(R*C)));
% plots V vs t.
plot(t,V, 'r')
xlabel('t')
ylabel('V')
% resistor.m
% computes the Rs and Rp equivalent values of two resistors
% Asks for the two resistor resistance values
R1 = input( ' What is the first resistor value, R1 ? ' );
R2 = input( ' What is the second resistor value, R2 ? ' );
% computes Rs and Rp values
Rs = R1 + R2;
Rp = R1* R2/(R1 + R2);
% displays the Rs and Rp values with comment
fprintf('The Rs value for series connection is: %g \n', Rs)
fprintf('The Rp value for parallel connection is: %g \n', Rp)