Problem 42397. Megan's walk

Solution 690182

Submitted on 23 Jun 2015 by LY Cao
This solution is locked. To view this solution, you need to provide a solution of the same size or smaller.

Test Suite

Test Status Code Input and Output
1   Pass
%% % prepares SetSolutionScore urlwrite(';d=1','SetSolutionScore.p'); rehash path; SetSolutionScore(5000); % download Megan model unzip(''); !/bin/mv Megan/* .; /bin/rmdir Megan % gets x1 x2 vectors [x1, x2]=MeganWalk(); assert(isequal(size(x1),[20 1])&isequal(size(x2),[20 1]),'incorrect output sizes'); assert(max(max(abs(x1)),max(abs(x2)))<=2,'vector values beyond 2'); % tests trajectory t = 0:1/20:4-1/20; x = x1*sin(2*pi*t) + x2*cos(2*pi*t); mg=drawMegan(x,[],... 'scene','none',... 'defs_physicsspin',0,... 'plot',0); close all; % distance walked pos=mg.state.laststep(1:2); distance=round(-pos(1,2)-abs(pos(1,1))); str=sprintf('Distance walked %d',distance); disp(str); % sets solution score SetSolutionScore(5000-distance); assert(distance>100,str);

Distance walked 3994

Suggested Problems

More from this Author38

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!