ode45 with discrete data
14 visualizaciones (últimos 30 días)
Mostrar comentarios más antiguos
José Anchieta de Jesus Filho
el 15 de Abr. de 2020
Comentada: Ameer Hamza
el 15 de Abr. de 2020
My problem consists of a differential equation in which, the damping coefficient of my system is not linear, it depends on the displacement
where, on the x axis is the displacement of the body and on the y axis is the damping coefficient for these positions.
I did the code in matlab and he did the calculation, however, I'm not sure if he did it correctly, since, in the damping coefficient curve, there is no coefficient for all positions.
An important point is, that I used the slipne function to get the equation, so, I wanted your help to understand a little more about the equation
And my question is more for, I know that the displacement of the system will be within the range that is in the graph of the damping coefficient, but does matlab understand that? why, although I haven't provided all the damping coefficient values, will the matlab integrate only in the range that I provided?
The other point is, I plotted the spline function and, from very high displacements, for my system, the damping coefficient starts to have negative values, so, I want to understand how the matlab can read this function and if it solves my problem in the range provided.
function testando
k1 = 116.0665; % N/m
m1 = 0.06; % kg
w = 25.1327; % rad/s
F1 = 0.01;% N
f1 = @(time) F1.*sin(w*time);
x = xlsread('emf.xlsx','B2:B62');
FT = xlsread('emf.xlsx','J2:J62');
x0 = 0; v0 = 0;
IC = [x0,v0];
% Time
t0 = 0; tf = 10;
tspan = [t0,tf];
%sdot = g(t,s)
sdot1 = @(t,s) [s(2);
(f1(t) - spline(x,FT,s(1)).*s(2) - k1.*s(1))./m1];
% Integração numerica
[time,state_values] = ode45(sdot1,tspan,IC);
displacement = state_values(:,1);
% plots
plot(time,displacement),xlabel('time(s)'),ylabel('displacement(m)')
title('Displacement(m) vs. t')
end
0 comentarios
Respuesta aceptada
Ameer Hamza
el 15 de Abr. de 2020
For your first question, yes, the spline function only uses the displacement value from vector 'x' the coefficient value from vector 'FT'. As long as the displacement value s(1) lies in the range of 'x', the MATLAB will use values in the range you provided.
For the second question, you are correct. The spline function can overshoot from the actual values. I recommend using interp1, which uses linear interpolation by default. The interpolated value will exactly look like the figure you attached.
sdot1 = @(t,s) [s(2);
(f1(t) - interp1(x,FT,s(1)).*s(2) - k1.*s(1))./m1];
5 comentarios
Más respuestas (0)
Ver también
Categorías
Más información sobre Splines 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!