Question & Answer: Write a MATLAB script called that plots the even and odd components of the function…..

Write a MATLAB script called that plots the even and odd components of the functions:

g(t) = 10*sin(20*pi*t)

x(t) = 8 + 7*(t^2)

This script will result in one figure, containing two columns, where each column will display three figure axes: top axis – original function; middle axis – the function’s even component; bottom axis – the function’s odd component. Use the MATLAB subplot() function to create these axis layouts. For example, the left column of the first figure should contain plots of g(t), ge(t), and go(t), from top to bottom. The right column of the first figure should contain the corresponding plots for problem x(t).

Hint: g(t) = ge(t) + go(t) = 0.5*[g(t) + g(-t)] + 0.5*[g(t) – g(-t)]

Expert Answer

 

MATLAB CODE:

%Declaring range of t

t = linspace(0,1,100);

%Creating g(t), g_o(t), g_e(t)

g = 10*sin(20*pi*t);

gminus = 10*sin(20*pi*(-t));

ge = (g+gminus)/2;

go = (g-gminus)/2;

%Creating x(t), x_o(t), x_e(t)

x = 8+7*(t.^2);

xminus = 8+7*((-t).^2);

xe = (x+xminus)/2;

xo = (x-xminus)/2;

%Sub-plotting g(t)

subplot(3,2,1);

plot(t,g);

ylabel(‘g(t)’);

xlabel(‘t’);

%Sub-plotting g_e(t)

subplot(3,2,3);

plot(t,ge);

ylabel(‘g_e(t)’);

xlabel(‘t’);

%Sub-plotting g_o(t)

subplot(3,2,5);

plot(t,go);

ylabel(‘g_o(t)’);

xlabel(‘t’);

%Sub-plotting x(t)

subplot(3,2,2);

plot(t,x);

ylabel(‘x(t)’);

xlabel(‘t’);

%Sub-plotting x_e(t)

subplot(3,2,4);

plot(t,xe);

ylabel(‘x_e(t)’);

xlabel(‘t’);

%Sub-plotting x_o(t)

subplot(3,2,6);

plot(t,xo);

ylabel(‘x_o(t)’);

xlabel(‘t’);

OUTPUT:

Still stressed from student homework?
Get quality assistance from academic writers!