increament in for loop does not working for impulse response

조회 수: 3 (최근 30일)
Tathagata Roy
Tathagata Roy 2021년 3월 14일
답변: Geoff Hayes 2021년 3월 14일
g=input("enter the lowest range of damping factror: ");
wn=input("enter the highest range of natural frequency= ");
%forloop%
for c= g:1
n=[wn.^2 0 0];
d=[1 2.*c.*wn wn.^2 ];
sys=tf(n,d);
impulse(sys,'r')
hold on
g=g+0.1;
end
  댓글 수: 1
Tathagata Roy
Tathagata Roy 2021년 3월 14일
I want to vary the value of damping constant in steps in each response( like 0.1,0.2,0.3, ...... ,1).
so I need to increase the value of given damping rato in steps. but the code is running for only the user input values for once that means onle on plot is showing which is the first case.
so please elp me to solve this one.

댓글을 달려면 로그인하십시오.

답변 (1개)

Geoff Hayes
Geoff Hayes 2021년 3월 14일
Tathagata - if the damping constant/factor is given by g, and you want to increment this value by 0.1 on each iteration of the loop (up to one), then just do
for c= g:0.1:1
where you include the increment of 0.1.

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by