Question: MATLAB CODE PLEASE The aim of this assignment is explore how sub-functions can be made available from a function file, via functional handles. The aim

MATLAB CODE PLEASE
The aim of this assignment is explore how sub-functions can be made available from a function file, via functional handles. The aim is to implement a simple stack in a file (mystack.m), where the main function passes back the three stack manipulation functions. A stack is a "last in first out" queue. The function file does not maintain any stack state, therefore the stack itself is passed in to functions, and then, when it's modified, the updated stack is returned. The file mystack.m contains the following functions: The code below shows a test case. The first call sets up the three stack functions so that they can be called. The variable stack is an array variable that holds the data. It is passed into functions, and also its modified value returned (from two of the functions). Implement a script that contains the following test code. [push, pop, peek] = mystack (); stack =[] stack = push ( stack, 100) >> stack =100 stack = push ( stack, 200) >> stack =200100 peek (stack) >> ans =200 stack = pop ( stack) >> stack =100 peek (stack) >> ans =100
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
