element wise operation column matrix
Mostrar comentarios más antiguos
I have a column matrix of data , Temp_data= [20;27;29;33;40] , i want to subtract each element i, by the first element (i.e 20-20; 27-20; 29-20;33-20), how do i do this?
also, how to do the similar operation if i have to subtract consequtive elements, i.e A(n) - A(n-1) [ex: 20-20; 27-20; 29-27....]
Respuestas (2)
Temp_data= [20;27;29;33;40]
Case_1 = Temp_data - Temp_data(1)
Case_2 = diff(Temp_data)
T = [20;27;29;33;40];
A = T - T(1)
B = [0;diff(T)]
1 comentario
Stephan
el 25 de Mayo de 2021
I thought about adding zero as first elemnt, since it is part of the desired result. But i think it does not meet the rquirement of A(n) - A(n-1) - so we'll see
Categorías
Más información sobre Resizing and Reshaping Matrices en Centro de ayuda y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!