0% found this document useful (0 votes)
24 views8 pages

Electrical Software Lab Assignments

Uploaded by

ayaanrehman777
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)
24 views8 pages

Electrical Software Lab Assignments

Uploaded by

ayaanrehman777
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

ELECTRICAL SOFTWARE AND

SIMULATION LAB

Name :- Ayaan Rehman ID :- 2023uee1549


Assignment :- 1
% Question1(a)- Calculate the rms value of a vector.
clc
clear
X=1:5
y=sqrt(mean(X.^2))

% Question1(b)- Graph of y=sin(x) on the interval x=0 to x=10


clc
clear
x=0:0.1:10
y=sin(x)
plot(x,y)
% Question2- Solve the set of linear algebraic equations
% 3a + 7b-1.5c=9 3.2b +c = 2 1/9 a -12b =0
clc
clear
A=[3 7 -1.5;0 3.3 1;1/9 -12 0]
B=[9;2;0]
X1=A\B
X2=inv(A)*B

% Question3 plot sin(x) and cos(x) over [0,2pi]


clc
clear
x = linspace(0,2*pi,100);
y = sin(x);
z = cos(x);
hold on
plot(x,y,'r');
plot(x,z,'g');
hold off
xlabel('X values')
ylabel('Y values')
title('plot of sin(X) and cos(X)')
%Question4 find the magnitude and angle of z = 5-3j
clc
clear
z = 5-3j;
Mag_z = abs(z);
angle_z = angle(z); % in radian
angle_z1 = angle_z*180/pi; % in degree

%Question5 find the imaginary and real part of v


clc
clear
num = (5+9i)*(7+1i);
den = (3-2i);
v = num/den;
a = real(v)
b = imag(v)
m = abs(v)
%Question6 find the roots of A
clc
clear
A = [5 3 2];
roots(A)

%Question7 find the value of the expression z


clc
clear
a=5; x=2; y=8;
z = exp(-a)*sin(x)+10*sqrt(y)

%Question8 find the current, voltage power dissipated


clc
clear
R=10; % resistance
I=0:2:10; % current
V = R*I % voltage
P = I.*V % power dissipated
sol = [I; V; P]
hold on;
plot(I,V,'r');
plot(I,P,'g');
xlabel 'current';
ylabel 'Y values';
title 'sample plot';
legend ('voltage','power');
hold off;
%Question9 create a 3x3 matrix
clc
clear
A = [3 9 1; 4 8 6; 8 2 0];
% part a
B = A(:,3);
% part b
C = A([1,2],:);
% part c
D = A(1,3)+A(2,3);
D1 = sum(A([1,2],3));
%Question10 sort the row and coloumn in descending order
clc
clear
A = [3 9 1; 4 8 6; 8 2 0];
% part a
A1 = sort(A,'descend');
% part b
A2 = sort(A,2,'descend');
% part c
[V, E] = eig(A);
% Question11- Solve y= (z^3 + 5z)/(4z^2 - 10)
% elements within the interval [1,11]
clc
clear
z=1:2:11;
y=(z.^3+5*z)./(4*z.^2-10)

% Question12 - Verify the trigonometric identity given by


% (cos(x/2))^2 =(tan(x) + sin(x) )/2 tan(x) for x= pi/5
clc
clear
x=pi/5;
LHS=cos(x/2)^2
RHS=(tan(x)+sin(x))/(2*tan(x))

Common questions

Powered by AI

The document uses MATLAB's 'roots()' function to find the roots of a polynomial, which is a straightforward approach to determining solutions to polynomial equations. This reflects MATLAB's capability to efficiently solve polynomials, leveraging numerical algorithms to provide solutions .

Euler's number is applied in the document within an expression involving the exponential function and the sine function. By using 'exp(-a)*sin(x)+10*sqrt(y)', it demonstrates the use of exponential decay in calculations, which is significant in modeling processes such as radioactive decay or depreciation that require an exponential decrease .

Linspace is used for generating linearly spaced vectors and is preferred when the number of points in an interval is specified, which guarantees the start and end points are included. In contrast, the colon operator is useful for specifying the increment between elements rather than the number of points. In the document, linspace is used to generate 100 points in the interval [0, 2π] for smoother plots, while the colon operator is used for simpler increments like in plotting 'y=sin(x)' over [0, 10].

The document calculates current as a range vector, voltage as the product of resistance and current, and power as the product of voltage and current. This representation allows analysis over a range of currents. The results are plotted with current on the x-axis and both voltage and power on the y-axis, using different colors to differentiate between the plotted variables .

The document computes eigenvalues and eigenvectors of a matrix using '[V, E] = eig(A)' in MATLAB. This operation identifies the directional scales of transformations represented by the matrix. Eigenvalues and eigenvectors have applications in stability analysis, vibration analysis, and principal component analysis, where they enable dimensionality reduction and system behavior prediction .

The document computes the real and imaginary parts of a complex division by multiplying two complex numbers and dividing by another. It uses the 'real()' and 'imag()' functions in MATLAB to separate these parts after the division is performed using standard complex multiplication and division formulas .

The document demonstrates matrix manipulation by creating a 3x3 matrix and performing operations like sorting elements in descending order for rows and columns. It uses the 'sort()' function in MATLAB for these purposes, reflecting an understanding of how to organize data within matrices for better analysis .

The RMS value of a vector in MATLAB is calculated by taking the square root of the mean of the squares of its elements. This is implemented using the expression 'y = sqrt(mean(X.^2))' where X is the vector .

The document uses matrix operations to solve the system of linear equations, specifically using the backslash operator '\' and the matrix inversion method 'inv()'. The backslash operator is generally preferred as it is computationally more efficient and numerically stable compared to explicitly computing the inverse of the matrix, which can introduce more round-off errors .

The document verifies a trigonometric identity by evaluating both the left-hand side and right-hand side of the equation at a specific value, x = π/5. While this confirms the identity holds for this value, it does not confirm the identity universally. The limitation is that multiple values should be tested or algebraic proof should be provided for general validity .

You might also like