How do I show the following condition t>1 with help of for-loop?

조회 수: 1 (최근 30일)
Sergey Dukman
Sergey Dukman 2015년 7월 6일
답변: Prateekshya 2024년 9월 2일
I am trying to plot the step response for different values of t. I choose condition when t is bigger than 1. I use the following script: function second_order = transfer_function(num,den) num=[1]; den=[1,2,1]; second_order=tf(num,den) for t=[1.1:0.1:10] step(second_order,t) end Is this written correct? Is there another way to plot step response when t>1?
Sergey

답변 (1개)

Prateekshya
Prateekshya 2024년 9월 2일
The code you have shared is indeed correct. It satisfies the condition t>1 while written in a for loop. Alternatively you can also use while loop to perform this.
% Initialize the time variable
t = 1.1;
% Use a while loop to iterate over time values
while t <= 10
% Plot the step response for the current time value
step(second_order, t);
% Increment the time variable
t = t + 0.1;
end
The above code is a sample code and will produce the same results as the for loop.
I hope this helps!

카테고리

Help CenterFile Exchange에서 MATLAB Report Generator에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by