replacing a element of an array and show them in certain way.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
If i want a output of an array like a=[4 -6 0 2 5 0 -6]. if I want to replace all the values to that are positive to 1 and print like a[0]= 1, a[1]= -6, a[2]= 0, a[3]= 1,..... and so on. what whould be tha code.
0 comentarios
Respuestas (1)
Chunru
el 24 de Jul. de 2021
a=[4 -6 0 2 5 0 -6]
a(a>0) = 1;
a
3 comentarios
John D'Errico
el 24 de Jul. de 2021
@Halsey Hal - Sorry, but Answers is not here to do homework assignments for people. This problem was given to you, so you would spend some time thinking about how to form strings composed of pieces for output, not so you would get the answer written for you online.
Ver también
Categorías
Más información sobre Elementary Math 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!