필터 지우기
필터 지우기

trying to loop for transfer function plots into single figure

조회 수: 4 (최근 30일)
Young Lee
Young Lee 2023년 9월 7일
댓글: Sam Chak 2023년 9월 8일
Parameters========================
Km1 = 0.01;
Km2 = 0.02257;
Km3 = 0.04;
Rm = 2.093;
b = 0.0000262;
t = 0.069;
T=0:0.0001:4;
========================================
something I tried, but It didnt work
for i :1:3
K(i) = Km(i)/(Rm*b+Km(i)^2);
oltf(i)=tf([K(i)],[t,(i)]);
step(i)=step(oltf(i),T);
plot(T, step(i),'r');
end
trying to fit all three plots into one figure
Thank you!!

채택된 답변

Dyuman Joshi
Dyuman Joshi 2023년 9월 7일
편집: Dyuman Joshi 2023년 9월 7일
%Do not name variables dynamically
%defining them in an array and using indexing is a much better option
Km = [0.01 0.02257 0.04];
Rm = 2.093;
b = 0.0000262;
t = 0.069;
T = 0:0.0001:4;
%Defining K via vectorization
K = Km./(Rm.*b+Km.^2);
%Initialise a figure and use hold on to retain plots on the same axes
figure
hold on
for i =1:3
oltf = tf([K(i)],[t,(i)]);
step(oltf,T)
%%It's not a good idea to use function names as variables names
%step(i)=step(oltf(i),T);
%%No need to use the plot command, as the step command itself outputs a plot
%plot(T, st(i),'r')
end
hold off
  댓글 수: 4
Young Lee
Young Lee 2023년 9월 8일
thanks for your kind help

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 2-D and 3-D Plots에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by