differentiate a 7000*6 matrix with a 7000*1 vector
조회 수: 1 (최근 30일)
이전 댓글 표시
Hi dear,
I am trying to differentiate a 7000*6 matrix with a 7000*1 vector. The details are:
The size of the matrix A_disp is 7000*6 containing the data of six motors' displacements,
and the size of the vector b_time is 7000*1 which is in fact the time series from 0 to 6999 seconds with an interval 1s.
Now I want to get the velocities of the six motors.
If the Matlab command "diff" is used to compute the velocity, so I need to write six times for the six columns of matrix A_disp, like
V1 = diff(A_disp(:,1))./diff(b_time) ; V2 = diff(A_disp(:,2))./diff(b_time) ; V3 = diff(A_disp(:,3))./diff(b_time) ; V4 = diff(A_disp(:,4))./diff(b_time) ; V5 = diff(A_disp(:,5))./diff(b_time) ; V6 = diff(A_disp(:,6))./diff(b_time) ;
But this way seems not smart and makes the codes in matlab look bulky.
Are there any codes can deal with this issue in a simple and compact way?
Thanks so much!
댓글 수: 0
답변 (1개)
Star Strider
2015년 10월 23일
As I understand the description of your problem, the code for your derivative would be:
h = mean(diff(b_time));
[~,V] = gradient(A_disp, h);
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!