A function that inserts an element into an array
2 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Seong Ho Yang
el 14 de Sept. de 2020
Comentada: Seong Ho Yang
el 14 de Sept. de 2020
So I am doing my homework on MatLab and I am baffled by this question given. It is to write a script that enters an element into an array at an index.
The array(A)'s size is 1 by N. The element(e) is the value that is entered. index(i) is the ith position of the array.
No specific array is provided.
All I know is that after the element has bee added the size of the array is now 1 by (N+1)
But beyond this, I don't even know where to start.
Please help! (explanation would be appreciated too!)
*note : this is an introductory class. So far, I have only covered functions, arrays
Respuesta aceptada
KSSV
el 14 de Sept. de 2020
Hints:
- To get length of an array use length.
- To get dimensions use size.
- If you have an array a, to access ith element: a(i)
- I can join two rwo arrays using [a b]
- I can join selected elements of a using [a(1:3) a(4) a(5:end)]
Try all the above steps in command window, you will get an idea how to complete your Home Work. Concentrate on the 5th point.
Más respuestas (0)
Ver también
Categorías
Más información sobre Matrix Indexing en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
