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
Get step-by-step solutions from verified subject matter experts
