Just Sharing Knowledge on Robotics, Electronics and Programming

Thursday, April 16, 2015

How to Create Circle Reference in Matlab



This is a simple problem but the question is how to implement it in a script ? .

Example circle Reference  is as a reference movement of a system , eg UAV aircraft, quadrotor , submarine ( AUV ) , Robot Manipulator and many others . Here are the steps to create circle references . you need to remember the concept of a circle in the XY plane is a circle formed of Sine on one axis and Cosine on another axis.

1. Open matlab simulink
     
2. Open the Library Browser

3. Select the User -defined Function and select Matlab Function . => add to Untitled

4. the Source , select the clock => add to Untitled

5. the Sink , select Scope => add to Untitled

5. the Sink , select the XY -Graph =>  add to Untitled

6. Double click on matlab function and type following script

function [x,y] = Circle(t)
freq = 0.1;
Gain = 10;
x = sin(freq*t)*Gain;
y = cos(freq*t)*Gain;

 Gain is used to enlarge the radius of the circle , the frequency for the speed trajectory .

6. then connect with the input clock t and scope and XY -Graph with output in matlab function block as shown below :



7. and then Run, so on X-Y Graph will showing the following result:


   
   

0 comments:

Post a Comment