Answered step by step
Verified Expert Solution
Question
1 Approved Answer
Cant seem to get this array right in MATLAB, its due at midnight EST 8 October. Please let me know how to correctly write this
Cant seem to get this array right in MATLAB, its due at midnight EST 8 October. Please let me know how to correctly write this code to check with the "Code to Call your Function" part at the bottom! I left what I have in there but its clearly wrong. Change what ever you need, just keep the function part. Thank you!
Array and Conditional Statement Write a function that takes an array as an input, and returns an array as an output. Your function should check to make sure that the array has more than one element. If it does not, it should return an empty array. If the array has more than one element, your output should be an array with two elements. The first element should be the first element of the nput array. The second element should be the last element of the input array Please look up the "length" function in MATLAB to help you with this problem. Your Function Save C Reset EE MATLAB Documentation function out = firstLast(in) out = [ ] L-length(in) if firstLast(1) else 4 5 out-in (1) out [in(1)in(1)1; 9 end Code to call your function C Reset 1 test1 = firstLast(4) 3 test2 = firstLast ([10 9 8 7 6 5 4 3 2 1])
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