필터 지우기
필터 지우기

matrix and steps in column

조회 수: 1 (최근 30일)
Jiung Shin
Jiung Shin 2020년 12월 6일
답변: Image Analyst 2020년 12월 6일
My matrix A is nx3 matrix and X is entry of A at (t,2) and t is assignmed in previous line.
I expressed it as X(t)=A(t,2). But when I ask for X(t+1), it returns this error:
Index exceeds the number of array elements (3).
Error in sym/subsref (line 907)
R_tilde =
builtin('subsref',L_tilde,Idx);
If I want to calculate X(t+1)-(X), how should I change my code?

답변 (1개)

Image Analyst
Image Analyst 2020년 12월 6일
Did you also assign X in advance? Why do you think there should be a t+1 element of X if you never assigned one?
n = 9;
A = rand(n, 3);
t = 4; % Whatever.
X(t) = A(t, 2); % Works fine
% The following won't work because X has only 4 elements, not 5
difference = X(t+1) - X(t); % There is no (t+1) element yet!
Not sure what you want to do Maybe you want this:
X = diff(A(:, 2);

카테고리

Help CenterFile Exchange에서 Logical에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by