Question: Use the Programming Language ---- > MATLAB Write a function with persistent variables currentLocationX and currentLocationY that store an object's location. Each call to the
Use the Programming Language ---- > MATLAB


Write a function with persistent variables currentLocationX and currentLocationY that store an object's location. Each call to the function adds deltaXCoord to currentLocationx and adds deltayCoord to currentLocationY. Assume a starting location of O for currentLocationX and currentLocationY. Your Function Save Reset MATLAB Documentation 1 function [endLocationx, endLocationY] = UpdateLocation(del taxcoord, del tavcoord) 2 % deltaxcoord: Move object along x axis 3 % deltaYCoord: Move object along y axis 4 % Declare a persistent variable currentlocationx % Declare a persistent variable current Location 5 6 8 9 18 % If currentlocationx is empty, assign currentlocationx with deltaxcoord % Otherwise, add deltaXCoord to currentlocationx currentLocationX = deltaxcoord; % If currentLocationY is empty, assign currentLocationY with deltaYCoord % Otherwise, add deltaYCoord to currentLocationV currentLocationY = deltaYCoord; 12 ES 14 15 16 1/ 18 19 end endLocationx = currentlocationx; endLocationY = currentLocationY; Code to call your function C Reset endLocationY] endLocationV] UpdateLocation (0, = UpdateLocation(2, 5) 3) 1 [endLocationx, = 2 [endLocationx, Run Function
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
