Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please use Matlab to plot this Code below: // Compute all way points float radiu

ID: 2081021 • Letter: P

Question

Please use Matlab to plot this Code below:

// Compute all way points

float radiusRate = 0;

float angleRate = 0;

// 10 circular spirals; each has 8 points.

for (int i = 0; i < 10;i++) {

for (int j = 0; j < 8; j++) {

trajectLocation[8*i+j].x = (i+1.0 + radiusRate) * cos(angleRate); // 0-7, 8-15, 16-23, etc.

trajectLocation[8*i+j].y = (i+1.0 + radiusRate) * sin(angleRate);

// trajectLocation[8*i+j].theta = atan2(trajectLocation[8*i+j].y - currentLocation.y, trajectLocation[8*i+j].x - currentLocation.x);

angleRate += 45*(M_PI/180);

radiusRate += 1.0/8.0; // small means tighter spiral, bigger means wider spiral

}

radiusRate = 0.0;

angleRate = 0.0;

}

Explanation / Answer

clear all
close all
clc
radiusRate = 0;
angleRate = 0;
M_PI=180;%In degrees

trajectLocation=zeros(10,8,2);
rad=zeros(10,8);
% 10 circular spirals; each has 8 points.
for i=1:10
for j=1:8
trajectLocation(i,j,1) = (i + radiusRate) * cos(deg2rad(angleRate));
trajectLocation(i,j,2) = (i + radiusRate) * sin(deg2rad(angleRate));
  
rad(i,j)=radiusRate;
  
angleRate = angleRate + 45*(M_PI/180);
radiusRate = radiusRate + 1.0/8.0;
  
  
end
radiusRate = 0.0;
angleRate = 0.0;
  
end

spiralx=[trajectLocation(1,:,1) trajectLocation(2,:,1) trajectLocation(3,:,1) trajectLocation(4,:,1) trajectLocation(5,:,1) trajectLocation(6,:,1) trajectLocation(7,:,1) trajectLocation(8,:,1) trajectLocation(9,:,1) trajectLocation(10,:,1) ];
spiraly=[trajectLocation(1,:,2) trajectLocation(2,:,2) trajectLocation(3,:,2) trajectLocation(4,:,2) trajectLocation(5,:,2) trajectLocation(6,:,2) trajectLocation(7,:,2) trajectLocation(8,:,2) trajectLocation(9,:,2) trajectLocation(10,:,2) ];

line(spiralx,spiraly)