Show value on the root locus plot without using the Data Cursor
49 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
MatlabNewbie01232015
am 11 Okt. 2013
Kommentiert: Prakhar Goel
am 26 Mai 2020
There are a large number of examples how to plot the root locus - using the rlocus function. The gain K can be showed from the graph with the Data Cursor. Is there anyway to show this value without using the Data Cursor but Matlab Code.
For example, I want to show Poles, Damping, Overshoot%, Frequency if K = 10 on the plot using Matlab code?
Thanks
0 Kommentare
Akzeptierte Antwort
Jonathan LeSage
am 15 Okt. 2013
The rlocus function can output the complex root locations and the corresponding gains. You can manually plot these values to replicate the plot generated by rlocus and then plot particular points of interest, such as the complex roots when K = 10.
You can also use the stepinfo function to acquire additional information, such as percent overshoot, to display. Using a method of this variety allows you to have full control over what you are displaying on your root locus plot!
Here is some code to get you started, and to introduce you to useful functions:
% Specify an arbitrary transfer function
G = tf([1 2],[1 4 13]);
% Pick gain to mark on root locus
gainToMark = 5;
% The rlocus function can output the values normally plotted and the gains
% associated with each value on the complex plane
[complexVec,gainsVec] = rlocus(G);
% Recall: the root locus is displayed on the complex plane (s = \sigma +
% j*\omega)
realPart = real(complexVec);
imagPart = imag(complexVec);
% First closed loop pole with increasing gain, K
realCLpole1 = realPart(1,:);
imagCLpole1 = imagPart(1,:);
% Second closed loop pole with increasing gain, K
realCLpole2 = realPart(2,:);
imagCLpole2 = imagPart(2,:);
% Plot the closed loop poles as varying with gain K
plot(realCLpole1,imagCLpole1,realCLpole2,imagCLpole2);
hold on;
ylabel('Imaginary Axis');
xlabel('Real Axis');
% Plot open loop poles
plot(realCLpole1(1),imagCLpole1(1),'bx'); hold on;
plot(realCLpole2(1),imagCLpole2(1),'bx');
% Plot open loop zeros
plot(realCLpole1(end),imagCLpole1(end),'bo'); hold on;
plot(realCLpole2(end),imagCLpole2(end),'bo');
% Find the the location of the gain of interest on the root locus
indexOfGain = find(gainsVec >= gainToMark,1,'first');
markedGain = gainsVec(indexOfGain);
% Form the closed-loop feedback system with selected gain
CLsystem = feedback(G,markedGain);
% Acquire step response values of interest from the closed-loop system
stepResponse = stepinfo(CLsystem);
percentOvershoot = stepResponse.Overshoot;
% Plot test box with results onto plot
gainString = ['Gain: ' num2str(markedGain)];
osString = ['%OS: ' num2str(percentOvershoot) ' %'];
text(-2.25,1.5,gainString);
text(-2.25,1.0,osString)
% Plot closed-loop poles arising from feedback gain selection
plot(realCLpole1(indexOfGain),imagCLpole1(indexOfGain),'r+');
plot(realCLpole2(indexOfGain),imagCLpole2(indexOfGain),'r+');
xlim([-10 2]); ylim([-4 4]);
Hope this helps!
2 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Classical Control Design finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!