Question: Here Sequence.m function : classdef sequence properties data offset end methods function s = sequence(data, offset) % SEQUENCE Sequence object % S = SEQUENCE(DATA, OFFSET)

Here Sequence.m function:

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

2) lab1.m write up

clear x = sequence([1 2 3 4 5], 1); y = sequence([5 3 1 -1 3 -2 2 3], -1); % test plus test_lab1('plus(x, y)') test_lab1('plus(y, x)') test_lab1('plus(1, x)') test_lab1('plus(x, 1)') y = sequence([5 3 1 0 3 -2 2 3], -4); test_lab1('plus(x, y)') test_lab1('plus(y, x)') % test minustract test_lab1('minus(x, y)') test_lab1('minus(y, x)') test_lab1('minus(1, x)') test_lab1('minus(x, 1)') % test timesiplication test_lab1('times(x, y)') test_lab1('times(3, x)') test_lab1('times(x, 3)') % test flip test_lab1('flip(x)') % test shift test_lab1('shift(y, 2)') %combinations test_lab1('flip(minus(shift(plus(x, 2), 4), y))') test_lab1('plus(flip(plus(x, y)), shift(y, -5))') test_lab1('minus(plus(times(shift(flip(x), 4), shift(y, 3)), flip(y)), x)') % test stem set(clf, 'Position', [200 200 400 200]) stem(flip(2+(x-shift(y, -4).*y-3))) title('y[n]'); % Program Listings fprintf(' ') disp('--- sequence.m --------------------------------') type sequence

Here Sequence.m function: classdef sequence properties data offset end methods function s

Q) Can someone edit lab1.m file so it can properly works when you type lab1 on the command line (I keep getting errors)

. You should download the following fles: sequence.m, lablm and test lablp .To test your code, just type lab1 on the command line. The program will report whether your code is returning the correct answers or not. Ifit is, you are done. If not, you can go back and correct things. . You should download the following fles: sequence.m, lablm and test lablp .To test your code, just type lab1 on the command line. The program will report whether your code is returning the correct answers or not. Ifit is, you are done. If not, you can go back and correct things

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!