plotting the correct position of maximum

4 ビュー (過去 30 日間)
Muhannad AL-hazmi
Muhannad AL-hazmi 2020 年 10 月 8 日
コメント済み: Ameer Hamza 2020 年 10 月 8 日
Hello
can you correct my code to find the right position of the max in the plot as you can see in the figure it's shifted to the right
clear;clc;
num = [0.1 0.35 0];
den = [1 3 2];
sys = tf(num,den)
figure();
step(sys);
grid
title('Respond of sytem Subjected to initial Conditoin')
xlabel('t')
ylabel('Output x(t)')
hold on;
max1 = max(step(sys));
min1 = min(step(sys));
plot(max1,'o')
plot(min1,'o')
legend('y(x)', sprintf('Maximum y = %0.4f',max1),sprintf('Minumum y = %0.3f',min1))

採用された回答

Ameer Hamza
Ameer Hamza 2020 年 10 月 8 日
編集済み: Ameer Hamza 2020 年 10 月 8 日
You also need to specify the time value in plot(). Try this
num = [0.1 0.35 0];
den = [1 3 2];
sys = tf(num,den);
figure();
step(sys);
[y, t] = step(sys);
grid
title('Respond of sytem Subjected to initial Conditoin')
xlabel('t')
ylabel('Output x(t)')
hold on;
[max1, idx1] = max(y);
[min1, idx2] = min(y);
plot(t(idx1), max1,'o')
plot(t(idx2), min1,'o')
legend('y(x)', sprintf('Maximum y = %0.4f',max1),sprintf('Minumum y = %0.3f',min1))
  4 件のコメント
Muhannad AL-hazmi
Muhannad AL-hazmi 2020 年 10 月 8 日
thank you
Ameer Hamza
Ameer Hamza 2020 年 10 月 8 日
I am glad to be of help!

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

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMATLAB についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by