Index Vector Operation in Matlab
Mostrar comentarios más antiguos
If the matrix A and the vector b
A = 5×5
13 2 3 3 10
14 5 15 7 1
2 9 15 14 13
14 15 8 12 15
10 15 13 15 11
b=[1 2 3 4 5]
and
>> C=A(b)
ans =
13 14 2 14 10
How to get element C by index in vector A(b) ?
4 comentarios
KALYAN ACHARJYA
el 26 de Ag. de 2019
What does it mean?
ans =
3 12 5 8 3
Is this expected ans?
James Tursa
el 26 de Ag. de 2019
It is unclear what you are trying to do, given that your code above does not produce the answer you post. E.g.,
>> A = [ 13 2 3 3 10
14 5 15 7 1
2 9 15 14 13
14 15 8 12 15
10 15 13 15 11];
>> b=[1 2 3 4 5];
>> C = A(b)
C =
13 14 2 14 10
Can you provide more explanation?
Johan Johan
el 26 de Ag. de 2019
James Tursa
el 26 de Ag. de 2019
Please restate your question. What do you mean by "get element C by index in vector A(b)"? Are you trying to do something like A(b)(2) to get at the 2nd element of C directly? If so, you cannot use that syntax in MATLAB.
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!