5 - MatLab Tutorial
5 - MatLab Tutorial
1 𝑅 2
𝑞 = 𝑞0 𝑒 −𝑅𝑡/(2𝐿)
𝑐𝑜𝑠 [ √ − ( ) 𝑡]
𝐿𝐶 2𝐿
where t = time, q0 = the initial charge, R = the resistance, L = inductance, and C =
capacitance. Use MATLAB to generate a plot of this function from t = 0 to 0.8, given that
q0 = 10, R = 60, L = 9, and C = 0.00005. (You can take the increment as 0.1 for time). Axis
labels should be bold and 12 points. Title should be bold and 14 points. Also there should
be a legend on the plot.
%% T(1)
% givens
q0 = 10;
R = 60;
L = 9;
C = 0.00005;
%% plotting
h = plot(t,q, 'LineWidth', 1.5, 'Color', 'c', 'Marker', 'h', 'MarkerSize', 12,
'MarkerFaceColor', 'k', 'MarkerEdgeColor', 'c');
title('Charge Variations within Time', 'FontSize', 14, 'FontWeight', 'bold');
xlabel('Time', 'FontSize', 12, 'FontWeight', 'bold');
ylabel('Charge', 'FontSize', 12, 'FontWeight', 'bold');
legend('q');
2. The standard normal probability density function is a bell-shaped curve that can be
represented as
1 −𝑧 2⁄
𝑓(𝑧) = 𝑒 2
√2𝜋
Use MATLAB to generate a plot of this function from z = -5 to 5. Label the ordinate as
frequency and the abscissa as z.
%% T(2)
% givens
z = -5:1:5;
f = (1/sqrt(2*pi))*exp(-z.^2/2);
plot(z,f);
xlabel('z');
ylabel('frequency');
3*. The trajectory of an object can be modeled as
𝑔 2
𝑦 = (𝑡𝑎𝑛𝜃0 )𝑥 − 𝑥 + 𝑦0
2𝑣02 𝑐𝑜𝑠 2 𝜃0