error while running a loop inside transfer function
조회 수: 2 (최근 30일)
이전 댓글 표시
i'm trying to change the value of k from to 0.1:0.1:7 and when i try this i get this error
??? Error using ==> InputOutputModel.subsasgn at 58
Subscript indices must either be real positive integers or logicals.
Error in ==> spect at 7
G(k)=tf([k],[10*10^-3 1]);
my code:
for k=0.1:0.1:7;
G(k)=tf([k],[10*10^-3 1]);
end
how can i fix that?
댓글 수: 0
채택된 답변
Walter Roberson
2013년 4월 18일
You are trying to assign the value of the tf() call into G(k) when k is not an integer. Subscripts must be positive integers.
kvals = 0.1 : 0.1 : 7;
for kidx = 1 : length(kvals)
k = kvals(kidx);
G(kidx) = tf([k],[10*10^-3 1]);
end
추가 답변 (1개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!