Question

In this problem you will use the cursor tracker code from the previous homework assignment to...

In this problem you will use the cursor tracker code from the previous homework assignment to measure frequency responses to various sinusoidal inputs and then generate a Bode plot. Use the Matlab file track cursor.m provided on Blackboard for a proportional controller with K = 0.1. After the tracker equilibrates, generate a sinusoidal input by moving the cursor back and forth and determine the gain and phase. The gain is the ratio of the amplitude of the output sinusoid over the amplitude of the input sinusoid, so if it tracks perfectly then the gain is 1 (0dB on a Bode plot). The phase is measured in degrees. 0 degrees is perfectly in phase, -180 degrees is perfectly out of phase. A slight lag behind the input will generate a negative phase (e.g. -25 degrees). You should use at least five input sinusoids of different frequencies. The lowest frequency input should be slow enough that the tracker is able to follow well (you may need to increase Nstop to get this data point), the fastest should be rapid enough that the tracker is not able to keep up, and the other three can be in between. Provide the input-output plots you used for each frequency and a table summarizing your estimates of the amplitude (in dB), phase (in degrees), and frequency (in rad/s). Use the data you gather to sketch a Bode plot.

The .m code referenced is as follows:

clear all, close all

% Identify screen resolution
set(0,'units','pixels')
screen_size = get(0,'screensize');
% Make figure the size of screen
figure('units','normalized','outerposition',[0 0 1 1])

% Number of time steps
Nstop = 150;

% Controller gain
K = 0.1;

for i = 1:Nstop
if i == 1 % initialize position of cursor tracker
y = 1;
end

axis([1 screen_size(3) 1 screen_size(4)]) % Set figure axes to size of screen

location = get(0, 'PointerLocation');
r = location(1); % Reference we are trying to track (horizontal position of cursor)
plot(r, 200, 'b.'); hold on % Plot a blue dot on horizontal position of cursor

e = r-y; % Error calculation
u = K*e; % Calculate control signal
  
y = y + u;
plot(y, 100, 'r.') % Plot a red dot on horizontal position tracking cursor
  
title([num2str(floor((i/Nstop)*100)), '% of Data Collection Time'])
pause(0.01)
end

Homework Answers

Answer #1

clear all, close all

% Identify screen resolution
set(0,'units','pixels')
screen_size = get(0,'screensize');
% Make figure the size of screen
figure('units','normalized','outerposition',[0 0 1 1])

% Number of time steps
Nstop = 150;

% Controller gain
K = 0.1;

for i = 1:Nstop
if i == 1 % initialize position of cursor tracker
y = 1;
end

axis([1 screen_size(3) 1 screen_size(4)]) % Set figure axes to size of screen

location = get(0, 'PointerLocation');
r = location(1); % Reference we are trying to track (horizontal position of cursor)
plot(r, 200, 'b.'); hold on % Plot a blue dot on horizontal position of cursor

e = r-y; % Error calculation
u = K*e; % Calculate control signal
  
y = y + u;
plot(y, 100, 'r.') % Plot a red dot on horizontal position tracking cursor
  
title([num2str(floor((i/Nstop)*100)), '% of Data Collection Time'])
pause(0.01)
end

Know the answer?
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
Similar Questions
Problem 1....... you can use Matlab The following Scilab code generates a 10-second “chirp” with discrete...
Problem 1....... you can use Matlab The following Scilab code generates a 10-second “chirp” with discrete frequencies ranging from 0 to 0.2 with a sampling frequency of 8 kHz. clear; Fs = 8000; Nbits = 16; tMax = 10; N = Fs*tMax+1; f = linspace(0.0,0.2,N); x = zeros(f); phi = 0; for n=0:N-1 x(n+1) = 0.8*sin(phi); phi = phi+2*%pi*f(n+1); end sound(x,Fs,Nbits); sleep(10000); //allows full sound to play Add code that calculates and plays y (n)=h(n)?x (n) where h(n) is the...
Problem 3 you can use Matlab and also i give u the Problem 1 code its...
Problem 3 you can use Matlab and also i give u the Problem 1 code its on Matlab Using the same initial code fragment as in Problem 1, add code that calculates and plays y (n)=h(n)?x (n) where h(n) is the impulse response of an IIR bandpass filter with band edge frequencies 750 Hz and 850 Hz and based on a 4th order Butterworth prototype. Name your program p3.sce this is the Problem 1 code and the solutin clear; clc;...
PLEASE USE MAT LAB ONLY. THANK YOU (a) Create and plot the signals listed below and...
PLEASE USE MAT LAB ONLY. THANK YOU (a) Create and plot the signals listed below and save your Matlab code in a script file. i) Cosine signal of frequency 100 Hz over the range [0,0.1] seconds and samples spaced 10^- 4 seconds apart with a phase of pi/2 and an amplitude of 1.   PLEASE USE MAT LAB ONLY. THANK YOU ii) A square wave that oscillates between 0 and 1 every five samples, plot 3 periods of the waveform. iii)...
Problem 1 ...... you can use Matlan i got one so all what i need is...
Problem 1 ...... you can use Matlan i got one so all what i need is 2, 3 and 4 one of them or all of them .. thanks The following Scilab code generates a 10-second “chirp” with discrete frequencies ranging from 0 to 0.2 with a sampling frequency of 8 kHz. clear; Fs = 8000; Nbits = 16; tMax = 10; N = Fs*tMax+1; f = linspace(0.0,0.2,N); x = zeros(f); phi = 0; for n=0:N-1 x(n+1) = 0.8*sin(phi); phi...