Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use matlab catmap shows below N. Set the axis limits for x to be 0 to the last value in the time vector and

please use matlab image text in transcribed
image text in transcribed
catmap shows below
image text in transcribed
N. Set the axis limits for x to be 0 to the last value in the time vector and y to -1 to 1 0. Turn off the hold toggle 2. FORMATTING PLOTS (20 PTS) Speaking of springs, Spring is in the air and soon caterpillars will soon be appearing on the landscape. We can use Matlab to make our own that might look like those in Fig. 2. Note that this particular type of caterpillar has solid cyan stars on its end segments and open stars on its middle segments. 00 8 8 2 1 0 To recreate something similar to Fig. 2, perform the following: A. Load the file ENGR131_Lab4_CatMap.mat into the workspace. This will produce a variable, CatMap, which is a 10 x 10 map of where the caterpillars are. B. Create a function that determines where the ends and middle segments are. Pass in CatMap as an input argument and output a modified map, CatMarks (10 pts) Fig. 2. Matlab plotted caterpillars on a 10 x 10 grid. The diamonds indicate the head. Filled in diamonds are hungry caterpillars. JUULI pui 10'U ND) C. To start, assign CatMap to a variable called CatMarks (ie. they're the same array) 1. Use nested for-loops with ranges equal to the number of rows and columns of the CatMap, ignoring the edges and scan the array element by element (ie. Do not scan through the first and last rows or columns) 2. In the case that an element in the map is a body segment (value of 1), add up the number of segments touching it. 3. Determine if this is an end segment based on the number of segments touching it. If it is, assign the value 2 to CatMarks in that location to indicate that it is an end. D. Create a new figure E. Change the background of the figure to green. Use the hold on command after this (5 pts). F. Call the function you created in part b. G. Because plots increase "upwards" where the rows of an array increase "downwards" flip CatMarks vertically and assign to a new variable for plotting. H. Scan the new plotting map using two nested loops - one for the rows and one for the columns of the plotting map 1. If the current element is above 0, mark it with a big, black circle using the various plotting properties to set the size, shape, and color (2.5 pts). Hint: you will be plotting a single point, not a vector as we have been doing. 2. Decide what marking to add to the segment (2.5 pts). a. A filled star if it is an end segment (a value of 2) b. An open star if it is a middle segment. 1. Set your axis limits to 10 x 10 J. Turn off the hold function importfile(fileToRead1) %IMPORTFILE(FILETOREAD1) % Imports data from the specified file -% FILETOREAD1: file to read % Auto-generated by MATLAB on 13-Mar-2021 07:11:35 % Import the file newDatal = load('-mat', fileToReadi); % Create bew variables in the base workspace from those fields. vars = fieldnames (newDatai); for i = 1: length(vars) assignin('base', vars{i}, newDatan. (vars{i})); end N. Set the axis limits for x to be 0 to the last value in the time vector and y to -1 to 1 0. Turn off the hold toggle 2. FORMATTING PLOTS (20 PTS) Speaking of springs, Spring is in the air and soon caterpillars will soon be appearing on the landscape. We can use Matlab to make our own that might look like those in Fig. 2. Note that this particular type of caterpillar has solid cyan stars on its end segments and open stars on its middle segments. 00 8 8 2 1 0 To recreate something similar to Fig. 2, perform the following: A. Load the file ENGR131_Lab4_CatMap.mat into the workspace. This will produce a variable, CatMap, which is a 10 x 10 map of where the caterpillars are. B. Create a function that determines where the ends and middle segments are. Pass in CatMap as an input argument and output a modified map, CatMarks (10 pts) Fig. 2. Matlab plotted caterpillars on a 10 x 10 grid. The diamonds indicate the head. Filled in diamonds are hungry caterpillars. JUULI pui 10'U ND) C. To start, assign CatMap to a variable called CatMarks (ie. they're the same array) 1. Use nested for-loops with ranges equal to the number of rows and columns of the CatMap, ignoring the edges and scan the array element by element (ie. Do not scan through the first and last rows or columns) 2. In the case that an element in the map is a body segment (value of 1), add up the number of segments touching it. 3. Determine if this is an end segment based on the number of segments touching it. If it is, assign the value 2 to CatMarks in that location to indicate that it is an end. D. Create a new figure E. Change the background of the figure to green. Use the hold on command after this (5 pts). F. Call the function you created in part b. G. Because plots increase "upwards" where the rows of an array increase "downwards" flip CatMarks vertically and assign to a new variable for plotting. H. Scan the new plotting map using two nested loops - one for the rows and one for the columns of the plotting map 1. If the current element is above 0, mark it with a big, black circle using the various plotting properties to set the size, shape, and color (2.5 pts). Hint: you will be plotting a single point, not a vector as we have been doing. 2. Decide what marking to add to the segment (2.5 pts). a. A filled star if it is an end segment (a value of 2) b. An open star if it is a middle segment. 1. Set your axis limits to 10 x 10 J. Turn off the hold function importfile(fileToRead1) %IMPORTFILE(FILETOREAD1) % Imports data from the specified file -% FILETOREAD1: file to read % Auto-generated by MATLAB on 13-Mar-2021 07:11:35 % Import the file newDatal = load('-mat', fileToReadi); % Create bew variables in the base workspace from those fields. vars = fieldnames (newDatai); for i = 1: length(vars) assignin('base', vars{i}, newDatan. (vars{i})); end

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Advances In Databases And Information Systems 14th East European Conference Adbis 2010 Novi Sad Serbia September 2010 Proceedings Lncs 6295

Authors: Barbara Catania ,Mirjana Ivanovic ,Bernhard Thalheim

2010th Edition

3642155758, 978-3642155758

More Books

Students also viewed these Databases questions