Hola, @Josepa Rico Salvador
Hola, Como el español no es mi lengua materna, responderé a esta pregunta en inglés. Gracias por su comprensión.
As per my understanding of your query, you wish to find the angle between two inertial sensors. I see in your code in the following lines-
q1 = fuse(accel1, gyro1, mag1);
q2 = fuse(accel2, gyro2, mag2);
The output of the 'fuse' object should be in form of [orientation,angularVelocity]. The orientation can either be in form of N-by-1 vector of 'quaternion'(default) or 3-by-3-by-N array of rotation matrices, where N is the number of samples.
Consider changing the above code lines to-
[q1,v1] = fuse(accel1, gyro1, mag1);
[q2,v2] = fuse(accel2, gyro2, mag2);
Further, you can refer to the documentation of 'complimentaryfilter' function for better understanding-
I hope this solves the issue you were facing!