Convert striaght lines to smooth curves
3 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
Pranav Shende
el 22 de Ag. de 2022
Comentada: Pranav Shende
el 27 de Ag. de 2022
Hi, I have acceleration and time data and want to create a phase diagram (displacement vs velocity).
My current plot looks like below fig 1, with straight lines connecting each point. Is it possible to change these to smooth curves as fig 2?
fig 1
fig 2
My current code is as below.
v = diff(Acc1).*diff(X_Value); %Acc1 = acceleration data and X_Value = Time
s = diff(v).*diff(X_Value(1:end-1));
figure
plot(s,v(1:end-1))
0 comentarios
Respuesta aceptada
Michael
el 22 de Ag. de 2022
It looks like your sample rate was too low. I'd recollect the data at a higher sample rate.
You could try doing a cubic spline interpolation on your acceleration data to estimate intermediate time points and then rerun your code.
dt = mean(diff(X_value));
t_hiRes = 0:dt/100:max(X_value);
hiresAccel1 = interp1(X_value, Acc1, t_hirRes,'cubic');
%Same for the rest
v = diff(Acc1).*diff(X_Value); %Acc1 = acceleration data and X_Value = Time
s = diff(v).*diff(X_Value(1:end-1));
figure
plot(s,v(1:end-1))
4 comentarios
Más respuestas (1)
John D'Errico
el 25 de Ag. de 2022
Why in the name of god and little green apples are you differentiating acceleration? You need to INTEGRATE acceleration, once to get velocity, then again to get displacement.
Differentiating acceleration results in noisy garbage, as it probably should. You differentiated the accelerations TWICE.
data = xlsread('starved_1000_001.lvm.xlsx');
T = data(:,1);
Acc = data(:,2);
vel = cumtrapz(T,Acc);
displacement = cumtrapz(T,vel);
plot(vel,displacement,'-')
3 comentarios
Michael
el 26 de Ag. de 2022
@Pranav Shende This might be due a DC bias in your accel measurement. This can happen if you have a bit of gravity measured in the axis of the accel. Try doing
a = a_raw - mean(a_raw)
to eliminate the bias. Also, be sure to accept the answer.
Ver también
Categorías
Más información sobre Descriptive Statistics en Help Center y File Exchange.
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!