MATRIX PROBLEM IN MATLAB

1 visualización (últimos 30 días)
Saptorshee Chakraborty
Saptorshee Chakraborty el 13 de Jun. de 2022
Comentada: Saptorshee Chakraborty el 13 de Jun. de 2022
Hello,
I have a simple question, why does regime (aa) is becoming 0 2
T=48;
B=3;
j = 1:B
j = 1×3
1 2 3
bk = 2:(T-2)
bk = 1×45
2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
regime = [0,bk,T-1]
regime = 1×47
0 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30
aa = 1:(j+1)
aa = 1×2
1 2
regime(aa)
ans = 1×2
0 2

Respuesta aceptada

David Hill
David Hill el 13 de Jun. de 2022
You are indexing into regime with an array (aa) which is 1:2. Not sure what you want array (aa) to be:
j=1:3;
aa=1:(j+1);%this will only take the first element of j, same as aa=1:2

Más respuestas (0)

Categorías

Más información sobre Matrices and Arrays en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by