Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PROBLEM 1 % Function to compute the length of the hypotenuse of a % right triangle given the lengths of the other two sides %

PROBLEM 1

% Function to compute the length of the hypotenuse of a

% right triangle given the lengths of the other two sides

%

% a - The length of one side

% b - The length of the other side

% c - The length of the hypotenuse

%

% function c = hyp(a,b)

%

function c = hyp(a,b)

c = sqrt(a^2 + b^2) ;

PROBLEM 2

% Unit-step function defined as 0 for input argument values

% less than zero, 1/2 for input argument values equal to zero,

% and 1 for input argument values greater than zero. This function

% uses the sign function to implement the unit-step function.

% Therefore value at t = 0 is defined. This avoids having undefined

% values during the execution of a program that uses it.

%

% function y = us(x)

function y = us(x)

y = (sign(x) + 1)/2 ;

PROBLEM 3

% Function to compute the ramp function defined as 0 for

% values of the argument less than or equal to zero and

% the value of the argument for arguments greater than zero.

% Uses the unit-step function us(x).

%

% function y = ramp(x)

%

function y = ramp(x)

y = x.*us(x) ;

PROBLEM 4

% Unit rectangle function. Uses the unit-step function us(x).

%

% function y = rect(x)

%

function y = rect(x)

y = us(x+0.5) - us(x-0.5) ;

PROBLEM 5

% Program to graph some demonstrations of continuous-time function combinations

t = 0:1/240:6 ; % Vector of time points for graphing x1

% Generate values of x1 for graphing

x1 = exp(-t).*sin(20*pi*t) + exp(-t/2).*sin(19*pi*t) ;

subplot(2,1,1) ; % Graph in the top half of the figure window

p = plot(t,x1,'k') ; % Display the graph with black lines

set(p,'LineWidth',2) ; % Set the line width to 2

% Label the abscissa and ordinate

xlabel('\itt','FontName','Times','FontSize',24) ;

ylabel('x_1({\itt})','FontName','Times','FontSize',24) ;

set(gca,'FontName','Times','FontSize',18) ; grid on ;

PROBLEM 6

t = -2:1/240:2 ; % Vector of time points for graphing x2

% Generate values of x2 for graphing

x2 = rect(t).*cos(20*pi*t) ;

subplot(2,1,2) ; % Graph in the bottom half of the figure window

p = plot(t,x2,'k') ; % Display the graph with black lines

set(p,'LineWidth',2) ; % Set the line width to 2

% Label the abscissa and ordinate

xlabel('\itt','FontName','Times','FontSize',24) ;

ylabel('x_2({\itt})','FontName','Times','FontSize',24) ;

set(gca,'FontName','Times','FontSize',18) ; grid on ;

PROBLEM 7

function y = g(t)

% Calculate the functional variation for each range of time, t

y1 = -4 - 2*t ; y2 = -4 + 3*t ; y3 = 16 - 2*t ;

% Splice together the different functional variations in

% their respective ranges of validity

y = y1.*(-2

% Program to graph the function, g(t) = t^2 + 2*t - 1 and then to

% graph 3*g(t+1), g(3*t)/2 and -2*g((t-1)/2).

tmin = -4 ; tmax = 20 ; % Set the time range for the graph

dt = 0.1 ; % Set the time between points

t = tmin:dt:tmax ; % Set the vector of times for the graph

g0 = g(t) ; % Compute the original g(t)

g1 = 3*g(t+1) ; % Compute the first change

g2 = g(3*t)/2 ; % Compute the second change

g3 = -2*g((t-1)/2) ; % Compute the third change

% Find the maximum and minimum g values in all the scaled or shifted

% functions and use them to scale all graphs the same

gmax = max([max(g0), max(g1), max(g2), max(g3)]) ;

gmin = min([min(g0), min(g1), min(g2), min(g3)]) ;

% Graph all four functions in a 2 by 2 arrangement

% Graph them all on equal scales using the axis command

% Draw grid lines, using the grid command, to aid in reading values

subplot(2,2,1) ; p = plot(t,g0,'k') ; set(p,'LineWidth',2) ;

xlabel('t') ; ylabel('g(t)') ; title('Original Function, g(t)') ;

axis([tmin,tmax,gmin,gmax]) ; grid ;

subplot(2,2,2) ; p = plot(t,g1,'k') ; set(p,'LineWidth',2) ;

xlabel('t') ; ylabel('3g(t+1)') ; title('First Change) ;

axis([tmin,tmax,gmin,gmax]) ; grid ;

subplot(2,2,3) ; p = plot(t,g2,'k') ; set(p,'LineWidth',2) ;

xlabel('t') ; ylabel('g(3t)/2') ; title('Second Change) ;

axis([tmin,tmax,gmin,gmax]) ; grid ;

subplot(2,2,4) ; p = plot(t,g3,'k') ; set(p,'LineWidth',2) ;

xlabel('t') ; ylabel('-2g((t-1)/2)') ; title('Third Change) ;

axis([tmin,tmax,gmin,gmax]) ; grid ;

% Program to graph the even and odd parts of a function

PROBLEM 8

function GraphEvenAndOdd

t = -5:0.1:5 ; % Set up a time vector for the graph

ge = (g(t) + g(-t))/2 ; % Compute the even-part values

go = (g(t) - g(-t))/2 ; % Compute the odd-part values

% Graph the even and odd parts

subplot(2,1,1) ;

ptr = plot(t,ge,'k') ; set(ptr,'LineWidth',2) ; grid on ;

xlabel('\itt','FontName','Times','FontSize',24) ;

ylabel('g_e({\itt})','FontName','Times','FontSize',24) ;

subplot(2,1,2) ;

ptr = plot(t,go,'k') ; set(ptr,'LineWidth',2) ; grid on ;

xlabel('\itt','FontName','Times','FontSize',24) ;

ylabel('g_o({\itt})','FontName','Times','FontSize',24) ;

PROBLEM 9

function y = g(x) % Function definition for g(x)

y = x.*(x.^2+3) ;

% Program to compute the signal energy or power of some example signals

dt = 0.1 ; t = -7:dt:13 ; % Set up a vector of times at which to compute the function. Time interval is 0.1

% Compute the function values and their squares

x = 4*exp(-t/10).*rect((t-4)/3) ;

xsq = x.^2 ;

Ex = trapz(t,xsq) ; % Use trapezoidal-rule numerical

% integration to find the area under

% the function squared and display the result

disp(['(a) Ex = ',num2str(Ex)]) ;

PLEASE HELP EXPLAIN ON HOW TO COMPLETE CODE. USING FOR MATLAB. THANK YOU.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Understanding Oracle APEX 5 Application Development

Authors: Edward Sciore

2nd Edition

1484209893, 9781484209899