Effacer les filtres
Effacer les filtres

matrix and steps in column

1 vue (au cours des 30 derniers jours)
Jiung Shin
Jiung Shin le 6 Déc 2020
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?

Réponses (1)

Image Analyst
Image Analyst le 6 Déc 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);

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by