quickwitted
Wednesday, December 25, 2019
Problem 6. Select every other element of a vector
Input x = [1 3 2 4 3 5]
Output y is [1 2 3]
Input x = [5 9 3 2 2 0 -1]
Output y is [5 3 2 -1]
Solution
function
y = everyOther(x)
[m,n]=size(x);
for
i=1:1:m
for
j=1:2:n
y1(i,j)=x(i,j);
end
end
y= y1(y1~=0);
end
ALL TEST SUITES SATISFIED AS PER CODY CHALLENGE.
No comments:
Post a Comment
Newer Post
Older Post
Home
Subscribe to:
Post Comments (Atom)
IELTS/TOFEL VOCABULARY SERIES
K-SERIES Watch the link before you answer : K-SERIES TUTORIAL 1 KEN A 2 KIN ...
(no title)
Problem 6. Select every other element of a vector Input x = [1 3 2 4 3 5] Output y is [1 2 3] Input x = [5 9 3 2 2 0 -1] Out...
Matlab Monday
Hi every one welcome to Matlab Monday. In this space I try to solve Matlab cody Problems.To start the solving marathon,my start point is at...
No comments:
Post a Comment