Homogenuous differential equation with conditions
1 visualizzazione (ultimi 30 giorni)
Mostra commenti meno recenti
Find and draw the first 22 terms of the solution of the homogeneous differential equation with the initial conditions: y[−1] = 0.6, y[−2] =
-8.2.
I dont understand what went wrong here?Dont understand how this work.
j=22;
y=[-8.2,0.6];
for i= -8.2:j+0.6
y(i)= 0.19*y(i-1)-0.36*y(i-2)+(0.31)^(i-3);
end
k=[-2:21];
stem(k,y);
"Array indices must be positive integers or logical values" problem
0 Commenti
Risposte (1)
Dyuman Joshi
il 31 Gen 2023
Modificato: Dyuman Joshi
il 31 Gen 2023
j=22;
y=[-8.2,0.6];
As you can see below, you are using non integer values as an index, which is not possible.
i = -8.2:j+0.6
MATLAB accepts only Natural numbers as index values. [1 2 3 4 ....] (or logical values, as the error clearly states)
Change the loop variable values
for i=3:22
y(i)= 0.19*y(i-1)-0.36*y(i-2)+(0.31)^(i-3);
end
k=[-2:19];
stem(k,y)
0 Commenti
Vedere anche
Categorie
Scopri di più su Loops and Conditional Statements in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!