Question

MATLAB codes please 3. Adapt the procedure developed in Example 6 to rotate the square counterclockwise by incre ments of /10

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Please comment if you need any clarification.

If you find my answer useful please put thumbs up. Thank you.

Question 3:

clf
% If you wish to verify the direction of rotation, you can
% create a spike in square by uncommenting these lines
% S=[-1,-1,1,1,-1.5,-1;
% -1,1,1,-1,-1.5,-1];

S=[-1,-1,1,1,-1; % square matrix
-1,1,1,-1,-1];
p=plot(S(1,:),S(2,:)); % plot the square
axis([-2 2, -2,2]); % adjust the axis limits
axis square, grid on
hold on

thetad = pi/10; % angle of rotations
t=ceil(2*pi/thetad); % no. of rotations required to complete a circle
D1 = [cos(thetad) sin(thetad); -sin(thetad) cos(thetad)]; % rotation matrix for counter-clockwise direction
for i=1:1:t
S=D1*S; % rotate the square
set(p,'xdata',S(1,:),'ydata',S(2,:)); % plot
pause(0.1);
end

D2 = [cos(thetad) -sin(thetad); sin(thetad) cos(thetad)]; % rotation matrix for clockwise direction
for i=1:t
S=D2*S; % rotate the square
set(p,'xdata',S(1,:),'ydata',S(2,:)); % plot
pause(0.1);
end
hold off

---------------------- SCREENSHOT OF CODE

roate_square.mx rotate_and_expand.mx + 1 - cit| 2 If you wish to verify the direction of rotation, you can 3 create a spike i

----------------------------- SAMPLE OUTPUT

1.5 0.5 OH -0.5 -1.5 -1.5 - 1 -0.5 0 0.5 1 1.5 2

Add a comment
Know the answer?
Add Answer to:
MATLAB codes please 3. Adapt the procedure developed in Example 6 to rotate the square counterclockwise...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • For this project, each part will be in its oun matlab script. You will be uploading a total 3 m f...

    For this project, each part will be in its oun matlab script. You will be uploading a total 3 m files. Be sure to make your variable names descriptive, and add comments regularly to describe what your code is doing and hou your code aligns with the assignment 1 Iterative Methods: Conjugate Gradient In most software applications, row reduction is rarely used to solve a linear system Ar-b instead, an iterative algorithm like the one presented below is used. 1.1...

  • PLEASE SHOW ALL WORK AND STEPS A wire loop carries a current i traveling in the...

    PLEASE SHOW ALL WORK AND STEPS A wire loop carries a current i traveling in the clockwise direction The loop is fixed in such a way that it can rotate about the axis (dashed line) shown in the figure. (a) In what direction will the magnetic field need to point for the loop to rotate counter clockwise, w hen viewed from above, about its axis? Explain the reasoning behind your answer. (A) Up (B) Down (C) Left (D) Right (E)...

  • MATLAB Thank you! Exercise: Bacteria Growth and Interpretation You can see that doing this with a...

    MATLAB Thank you! Exercise: Bacteria Growth and Interpretation You can see that doing this with a for loop can be easier than repeatedly typing the same commands for every a value. Using a for loop also makes the desired values or parameters easier to change Consider various populations of bacteria whose populations are modelled by the function P(t) 100 e a.Sat, where P(t) is the population, t is the time in hours, and a is some positive constant. Your job...

  • You are given a finite step function xt=-1  0<t<4 1  4<t<8.           Hand calculate the FS coefficients of...

    You are given a finite step function xt=-1  0<t<4 1  4<t<8.           Hand calculate the FS coefficients of x(t) by assuming half- range expansion, for each case below. Modify the code below to approximate x(t) by cosine series only (This is even-half range expansion). Modify the below code and plot the approximation showing its steps changing by included number of FS terms in the approximation. Modify the code below to approximate x(t) by sine series only (This is odd-half range expansion).. Modify...

  • 2.1 Summary In this part, you will create a figure, and use linear transformations (matrices) to ...

    2.1 Summary In this part, you will create a figure, and use linear transformations (matrices) to move the figure around the screen. In the end, your figure should move up 8 steps, then turn and face left. Reference material for this part can be found in Linear Algebra, and its applications, David Lay, Section 2.7 starting at the beginning of the section up to, but not incluing,3D Graphics. Also, this poster presentation does a pretty good job explaining the same...

  • PLEASE DO IN MATLAB Problem 8 (PID feedback control). This problem is about Proportional-Integral-Derivative feedback control...

    PLEASE DO IN MATLAB Problem 8 (PID feedback control). This problem is about Proportional-Integral-Derivative feedback control systems. The general setup of the system we are going to look at is given below: e(t) u(t) |C(s) y(t) P(s) r(t) Here the various signals are: signal/system r(t) y(t) e(t) P(s) C(s) и(t) meaning desired output signal actual output signal error signal r(t) y(t) Laplace transform of the (unstable) plant controller to be designed control signal Our goal is to design a controller...

  • MATLAB ONLY gauss.jpg BELOW Instructions: The following problems can be done interactively or by writing the...

    MATLAB ONLY gauss.jpg BELOW Instructions: The following problems can be done interactively or by writing the commands iın an M-file (or by a combination of the two). In either case, record all MATLAB input commands and output in a text document and edit it according to the instructions of LAB 1 and LAB 2. For problem 2, include a picture of the rank-1 approximation. For problem 3, include a picture of the rank-10 approximation and for problem 4, include a...

  • Newton's Method in MATLAB During this module, we are going to use Newton's method to compute...

    Newton's Method in MATLAB During this module, we are going to use Newton's method to compute the root(s) of the function f(x) = x° + 3x² – 2x – 4 Since we need an initial approximation ('guess') of each root to use in Newton's method, let's plot the function f(x) to see many roots there are, and approximately where they lie. Exercise 1 Use MATLAB to create a plot of the function f(x) that clearly shows the locations of its...

  • Can you please help me with this question. Much appreciated. So I have a sample code,...

    Can you please help me with this question. Much appreciated. So I have a sample code, but we need to change the code in a way that fits the problem. A planar slab of material is initially at a temperature of 300 K. At the time t=0, microwave radiation is directed at the material, leading to internal heat generation that is uniform within the material. The sides of the slab experience negligible heat losses and a water bath maintains the...

  • Unable to correct errors from my MatLab Script and would like to see a script to...

    Unable to correct errors from my MatLab Script and would like to see a script to compare mine to. Write a MatLab script that simulates a virus spread. This problem needs the following parts, some of which are nested loops, ie Part 3, 4 and 5 are nested in Part 2’s loop (for or while): To build the program first to only deal with infection transmission within the town’s neighbors An array which for every person in the town which...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT