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
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