MATLAB: Calculate the resultant vector for 3 axis of data

code generationpythagorasvector

I have an 9 axis sensor and I have the data in matlab. I am wanting to calculate the resultant vector of acceleration, the resultant angular velocity for gyroscope.. and magnetometer.
In excel i would simply SQRT(accx^2+accy^2+accz^2) . this would be the resultant.
My question is how do i calculate this? Then, how do I automatically calculate this for every data point?
Thankyou!!

Best Answer

% some random data for demo
accx = rand(10,1) ;
accy = rand(10,1) ;
accz = rand(10,1) ;
R = sqrt(accx.^2+accy.^2+accz.^2) ;