Question: classdef sequence properties data offset end methods function s = sequence(data, offset) % SEQUENCE Sequence object % S = SEQUENCE(DATA, OFFSET) creates sequence S %
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
%
% Your Name 1 Jan 2014
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
Purpose This is a brief tutorial on Matlab to help you get started. Matlab has a number of core deficiencies, but the most severe for our purposes is that addressing of arrays in Matlab follows the ones-based indexing convention of an ancient programming language, FORTAN, meaning that the first element of an array, s, is s(1), not s(0), as it would be in C, C++, Java or other modern languages with zero-based indexing. In your assignment, you'll use Matlabs object-oriented programming language to create a sequence class that solves this problem. Purpose This is a brief tutorial on Matlab to help you get started. Matlab has a number of core deficiencies, but the most severe for our purposes is that addressing of arrays in Matlab follows the ones-based indexing convention of an ancient programming language, FORTAN, meaning that the first element of an array, s, is s(1), not s(0), as it would be in C, C++, Java or other modern languages with zero-based indexing. In your assignment, you'll use Matlabs object-oriented programming language to create a sequence class that solves this
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
