0% found this document useful (0 votes)
17 views

My MATLAB Solutions

This document contains 3 sections that define functions in MATLAB: 1) A function to calculate velocity and distance given initial velocity, acceleration due to gravity, and time. 2) A function that plots the voltage and current of an RL circuit over time. 3) A function that performs matrix multiplication on 2x2 matrices by prompting the user to input values for each element.

Uploaded by

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

My MATLAB Solutions

This document contains 3 sections that define functions in MATLAB: 1) A function to calculate velocity and distance given initial velocity, acceleration due to gravity, and time. 2) A function that plots the voltage and current of an RL circuit over time. 3) A function that performs matrix multiplication on 2x2 matrices by prompting the user to input values for each element.

Uploaded by

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

Question 3

function exam_2019()
g = input("Enter the value of v");
v0 = input("Enter the value of v0");
t = input("Enter the value of t");

disp('The value of velocity is: ')


v = v0 + g*t

disp('The value of distance is: ')

d = v0 * t + (0.5 * g * t^2)

end
Question 5

t = 0:1E-3:20E-3;

v = 10*cos(377*t);

a_rad = (60*pi/180); % angle in radians


i = 5*cos(377*t + a_rad);

plot(t,v,'*',t,i,'o')
title('Voltage and Current of an RL circuit')
xlabel('Sec')
ylabel('Voltage(V) and Current(mA)')
text(0.003, 1.5, 'v(t)');
text(0.009,2, 'i(t)')
2 by 2 matrix multiplaction

function result = matrixlaju(a, b)


a(1, 1) = input("Enter the value of a11");
a(1, 2) = input ("Enter the value of a12");
a(2, 1) = input ("Enter the value of a21");
a(2, 2) = input ("Enter the value of a22");
b(1, 1) = input("Enter the value of b11");
b(1, 2) = input ("Enter the value of b12");
b(2, 1) = input ("Enter the value of b21");
b(2, 2) = input ("Enter the value of b22");
result = a*b
end

You might also like