Filter löschen
Filter löschen

matrix entry into function

1 Ansicht (letzte 30 Tage)
Jiung Shin
Jiung Shin am 6 Dez. 2020
Beantwortet: Cris LaPierre am 6 Dez. 2020
In a matrix A, I have assinged x(t)=A(t,2)
But if I want to calculate x(t+1)-x(t), it returns an error. How can I fix? Matlab doesn't specify which error I have made.
+ is it possible that I write a function and when I execute it it returns a message with enter "t" so I don't have to rewrite the code for different t? I think I did something similar in python or some other language but I'm not sure with matlab.
  1 Kommentar
KSSV
KSSV am 6 Dez. 2020
Bearbeitet: KSSV am 6 Dez. 2020
Show us your code. Or how A is related to t.

Melden Sie sich an, um zu kommentieren.

Antworten (1)

Cris LaPierre
Cris LaPierre am 6 Dez. 2020
Also, share the complete error message (all the red text),
My suspicion is that x(t+1) does not exist.
x=1:5;
t=5;
x(t+1)-x(t)
Index exceeds the number of array elements (5).

Kategorien

Mehr zu MATLAB finden Sie in Help Center und File Exchange

Produkte

Community Treasure Hunt

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

Start Hunting!

Translated by