matrix and steps in column
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
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?
0 Kommentare
Antworten (1)
Image Analyst
am 6 Dez. 2020
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);
0 Kommentare
Siehe auch
Kategorien
Mehr zu Logical finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!