Hi Debora,
The function btkSetAnglesValues works as following:
- From the given acquisition
1. Extract angles
2. Compare their dimensions with the dimensions of the given data
3. Set angles' values with given data.
In your case, you have an error in the step 2. Indeed the step 1 return an empty set of angles as you create a new acquisition with by default only markers.
So your code should be modified like this:
acq=btkNewAcquisition(20,2200)
btkSetFrequency(acq,200)
for i = 1:20
btkSetPointType(acq, i, 'Angle'); % The new type of the point
btkSetPoint(acq, i, data(i,:,1:3)) % the variable data is 20x2200x3
end
btkWriteAcquisition(acq,'PrimaProva.c3d')
It is also important to write the acquisition at the end, otherwise all modifications done after in the acquisition won't be saved.
Finally, you can also use the function btkAppendPoint. The code will be slightly different:
acq=btkNewAcquisition(0,2200) % No points
btkSetFrequency(acq,200)
for i = 1:20
btkAppendPoint(acq, 'Angle', ['Angle',num2str(i)], data(i,:,:));
% Other example where labels is a cell of strings % btkAppendPoint(acq, 'Angle', labels{i}, data(i,:,:));
end
btkWriteAcquisition(acq,'PrimaProva.c3d')Arnaud