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

Use the Programming Language ---- > MATLAB Write a function with persistent

variables currentLocationX and currentLocationY that store an object's location. Each call to

Write a function with persistent variables currentLocationX and currentLocationY that store an object's location. Each call to the furiction adds deltaXCoord to currentLocationX and adds deltaYCoord to currentLocationY. Assume a starting lccation of 0 for currentLocationX and currentLocationY Your Function Save C Reset MAILAB Documentation 1 function [endl ocationx, endl ocatinny]ndatel ncation(deltaxcnnrd, deltaYcoord) 21% dellaxcoord; Move objecl along x axis % deltavcnnrd: Move object along y axis Declare a persistent variable rurrenti ocation % Declare ia persislenl variable uurrenLLocalionY % If curren!LUCdLionx is emply, assign currenlLocalionx wilh delLaxCoor otherwise, add del taxcoord to current location currenlloaiox- dellaxCourd % If currenLLUCdLiorIY is emply, assigi currenlLocalionY wilh dellayCoor otherwise, add del tavcoord to current locationY currernlLocaliuny -dellaYCourd; ekLocalionx - currenocaiox; endlocationY-currentl oratinnY; end Code to call your function C Resel edLocatix, endocationy UpdteLocation(, s) endLocationX, endLocationY] - UpdateLocation(2, 3) Write a function with persistent variables currentLocationX and currentLocationY that store an object's location. Each call to the furiction adds deltaXCoord to currentLocationX and adds deltaYCoord to currentLocationY. Assume a starting lccation of 0 for currentLocationX and currentLocationY Your Function Save C Reset MAILAB Documentation 1 function [endl ocationx, endl ocatinny]ndatel ncation(deltaxcnnrd, deltaYcoord) 21% dellaxcoord; Move objecl along x axis % deltavcnnrd: Move object along y axis Declare a persistent variable rurrenti ocation % Declare ia persislenl variable uurrenLLocalionY % If curren!LUCdLionx is emply, assign currenlLocalionx wilh delLaxCoor otherwise, add del taxcoord to current location currenlloaiox- dellaxCourd % If currenLLUCdLiorIY is emply, assigi currenlLocalionY wilh dellayCoor otherwise, add del tavcoord to current locationY currernlLocaliuny -dellaYCourd; ekLocalionx - currenocaiox; endlocationY-currentl oratinnY; end Code to call your function C Resel edLocatix, endocationy UpdteLocation(, s) endLocationX, endLocationY] - UpdateLocation(2, 3)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!