array concatenation problem in matlab

How can I add up on array without using concatenation or inbuilt function in matlab? I just want to combine the values in array.

 Respuesta aceptada

Shivani Dixit
Shivani Dixit el 27 de Jun. de 2021
Assuming any inbuilt function should not be used, you can add up one array to other by the following method :
% assume this to be your initial array
x=[1 2 3]
% now suppose a new value is to be added i.e 4
x=[x 4]
This method concatenates values to the array without using any inbuilt function in matlab.

3 comentarios

Samriddhi Kumari
Samriddhi Kumari el 27 de Jun. de 2021
Hi Shivani, your explanation was very lucid. Thanks.
Stephen23
Stephen23 el 27 de Jun. de 2021
Editada: Stephen23 el 27 de Jun. de 2021
"Assuming any inbuilt function should not be used,"
Note that square brackets are just syntactic sugar for HORZCAT and VERTCAT, both of which are inbuilt functions:
which vertcat
built-in (/MATLAB/toolbox/matlab/ops/vertcat)
which horzcat
built-in (/MATLAB/toolbox/matlab/ops/horzcat)
Shivani Dixit
Shivani Dixit el 7 de Jul. de 2021
A good catch , but as per the query , i assume that in this context, built-in means not to use any ready-made functions that concatenates the array.

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Creating and Concatenating Matrices en Centro de ayuda y File Exchange.

Productos

Etiquetas

Preguntada:

el 27 de Jun. de 2021

Comentada:

el 7 de Jul. de 2021

Community Treasure Hunt

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

Start Hunting!

Translated by