Is it possible to create "SettlingTime" and "Overshoot" datatips on a stepplot via scripts?

3 ビュー (過去 30 日間)
Alex Oleg
Alex Oleg 2019 年 11 月 5 日
回答済み: elad sharony 2022 年 7 月 9 日
I have a stepplot responce. I need to create datatips automatically on "SettlingTime" and "Overshoot" points (see the picture below).
I know how to create datatips on simple x,y plots using the "cursorMode.createDatatip", but it seems like this command can't be used with the stepplot.
Next script allows me to get the characteristic points:
h=figure ('units','normalized','outerposition',[0 0 1 1]);
step_sys=stepplot(sys);
step_sys.showCharacteristic('SettlingTime');
step_sys.showCharacteristic('PeakResponse');
Maybe exist any command to add lables on this plot?
Сварка.png
1st plot: What I have.
2st plot: What I need to have.
  1 件のコメント
Jose Daniel Pinzon Vivas
Jose Daniel Pinzon Vivas 2021 年 2 月 18 日
編集済み: Jose Daniel Pinzon Vivas 2021 年 2 月 18 日
Same problem here. And it seems that there is still no answer. I'm trying to do it in a live editor, but I can't get the data tips.

サインインしてコメントする。

回答 (2 件)

Jose Daniel Pinzon Vivas
Jose Daniel Pinzon Vivas 2021 年 2 月 18 日
This is the answer that a came with.
h=stepplot(sys_cl,t);
s_info=stepinfo(sys_cl);
grid
title('Step Response with Text')
h.showCharacteristic('PeakResponse')
h.showCharacteristic('SettlingTime')
h.showCharacteristic('SteadyState')
text(s_info.PeakTime+0.05,h.Responses.Data.Amplitude(end)*0.6,sprintf('PeakTime (s) = %.3f', s_info.PeakTime))
text(s_info.PeakTime+0.05,s_info.Peak,sprintf('Overshoot (%%) = %.3f', s_info.Overshoot))
text(s_info.SettlingTime+0.05,h.Responses.Data.Amplitude(end)*0.4,sprintf('SettlingTime (s) = %.3f', s_info.SettlingTime))
text(h.Responses.Data.Time(end)*0.5,h.Responses.Data.Amplitude(end)*1.05,sprintf('Final Value (s) = %.3f', h.Responses.Data.Amplitude(end)))

elad sharony
elad sharony 2022 年 7 月 9 日
P = tf(1,[1,0.4,1]);
fig = figure;
plt = stepplot(P);
plt.showCharacteristic('SettlingTime')
plt.showCharacteristic('RiseTime')
CharPoints = findall(get(fig,'Children'),'type','line','Tag','CharPoint');
for i = 1:length(CharPoints)
datatip(CharPoints(i),'Visible','on','DataIndex',i,'Location','southeast','FontSize',8);
end

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by