i have a column matrix [23; 34;22;13]. i need to create set of column matrixs ,which give 1 and -1 in numbers if the next number is less than and larger than.
1 visualización (últimos 30 días)
Mostrar comentarios más antiguos
shashika iresh
el 2 de Oct. de 2016
Comentada: shashika iresh
el 4 de Oct. de 2016
A=[23; 34;22;13] output matrixs=[1;-1;-1],[-1,-1],[-1]
0 comentarios
Respuesta aceptada
Más respuestas (1)
Atsushi Ueno
el 2 de Oct. de 2016
Editada: Atsushi Ueno
el 3 de Oct. de 2016
I have modified the last answer after getting your comment.
A = [23; 34; 22; 13];
B = sign(diff(A));
matrixs = {0};
for i = numel(B):-1:1
matrixs = {B(i:end), matrixs{:}};
end
0 comentarios
Ver también
Categorías
Más información sobre Loops and Conditional Statements en Help Center y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!