Question: Write a MATLAB code sequence following functions: classdef sequence properties data offset end methods function s = sequence(data, offset) % SEQUENCE Sequence object % S

Write a MATLAB code sequence following functions:

classdef sequence

properties

data

offset

end

methods

function s = sequence(data, offset)

% SEQUENCE Sequence object

% S = SEQUENCE(DATA, OFFSET) creates sequence S

% using DATA and OFFSET

%

s.data = data;

s.offset = offset;

end

function display(s)

var = inputname(1);

if (isempty(var))

disp('ans =');

else

disp([var '=']);

end

switch length(s.data)

case 0

disp(' data: []')

case 1

disp([' data: ', num2str(s.data)])

otherwise

disp([' data: [' num2str(s.data) ']'])

end

disp([' offset: ' num2str(s.offset)])

end

function y = flip(x)

% FLIP Flip a Matlab sequence structure, x, so y = x[-n]

end

function y = shift(x, n0)

% SHIFT Shift a Matlab sequence structure, x, by integer amount n0 so that y[n] = x[n - n0]

end

function z = plus(x, y)

% PLUS Add x and y. Either x and y will both be sequence structures, or one of them may be a number.

end

function z = minus(x, y)

% MINUS Subtract x and y. Either x and y will both be sequence structures, or one of them may be a number.

end

function z = times(x, y)

% TIMES Multiply x and y (i.e. .*) Either x and y will both be sequence structures, or one of them may be a number.

end

function stem(x)

% STEM Display a Matlab sequence, x, using a stem plot.

end

end

end

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!