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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started