differentiate a 7000*6 matrix with a 7000*1 vector
2 Ansichten (letzte 30 Tage)
Ältere Kommentare anzeigen
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 Kommentare
Antworten (1)
Star Strider
am 23 Okt. 2015
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 Kommentare
Siehe auch
Produkte
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!