Question: I have this function IN MATLAB function y = even(x) while x.data(1) == 1 x.data(1) = 0; x.data(1) = []; x.offset = x.offset + 1;

I have this function IN MATLAB

function y = even(x)

while x.data(1) == 1

x.data(1) = 0;

x.data(1) = [];

x.offset = x.offset + 1;

end

end

GIVES ME THIS OUTPUT

>> x = sequence([1 4 3 -2 6], -1);

>> xe = even(x)

xe=

data: [4 3 -2 6]

offset: 0

>> x = sequence([1 4 3 -2 6], -1);

>> xe = even(x)

Output argument "y" (and maybe others) not assigned during call to "even".

THE CORRECT OUTPUT IS:

>> x = sequence([1 4 3 -2 6], -1);

>> xe = even(x)

xe=

data: [3 -1 2 4 2 -1 3]

offset: -3

COULD YOU TELL ME PLEASE WHAT I NEED TO CHANGE IN MY CODE TO GET THE CORRECT OUTPUT

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!