Borrar filtros
Borrar filtros

How change only second number in a=ones(1,10)?

1 visualización (últimos 30 días)
Bajdar Nouredine
Bajdar Nouredine el 16 de En. de 2024
Respondida: Jaime Abad Arredondo el 16 de En. de 2024

Respuesta aceptada

Dyuman Joshi
Dyuman Joshi el 16 de En. de 2024
Simply use indexing to change the element -
a = ones(1,10);
a(2) = 2
a = 1×10
1 2 1 1 1 1 1 1 1 1

Más respuestas (1)

Jaime Abad Arredondo
Jaime Abad Arredondo el 16 de En. de 2024
You should look at the syntax for array slicing. In matlab it's fairly easy. You would do something like:
a=ones(1,10);
disp(a)
1 1 1 1 1 1 1 1 1 1
a(2)=2;
disp(a)
1 2 1 1 1 1 1 1 1 1
Cheers!

Categorías

Más información sobre Creating and Concatenating Matrices 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