필터 지우기
필터 지우기

why i'm getting this error

조회 수: 1 (최근 30일)
ocsse
ocsse 2018년 5월 10일
답변: OCDER 2018년 5월 10일
Hi all, i'm trying to use a loop to store the impulse of the systems but I'm getting the following error: Unable to perform assignment because the indices on the left side are not compatible with the size of the right side.
also there are two warnings for y(n) and t(n) that say: the variables appear to change size on every loop iteration
for n = 1:4
[y(n), t1(n)] = impulse(sys(n));
end
any help would be appreciated. thanks

채택된 답변

OCDER
OCDER 2018년 5월 10일
If the outputs of impulse are not scalor values, then store the output into a cell, where each cell can store a different size and type of data. Preallocating variables y and tl will speed things up and get rid of the warning message. https://www.mathworks.com/help/matlab/matlab_prog/preallocating-arrays.html
y = cell(1, 4);
t1 = cell(1, 4);
for n = 1:4
[y{n}, t1{n}] = impulse(sys(n));
end

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Matrix and Vector Construction에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by