Varying stiffness with time

Hello
I am trying to approximate a crash pulse using a simple mass spring model. Using piecewise linear least squares and a Force against displacement plot i have found the stiffness of different sections.
graph.jpg
I am now trying to vary the stiffness (k) in my mass spring model in simulink between given time intervals (0:0.01689, 0.01689: 0.04, and 0.04:0.05625)
I have tried using for and if statements to achieve this to no avail.
m=1078;
A = table2array(T); % T is the crash data supplied (displacement, acceleration, and time)
Displ = A(:,1);
Accel = A(:,2);
Time = A(:,3);
Forc = m*Accel;
%{
%% if funciton
if Time < 0.0281
k = 111032.0285;
elseif Time >= 0.0281
k = 1176198.934;
end
%}
% using if does not work and so instead, my plot gives the k1 and k2 plots over the whole time duration instead of between 0:0.01689, and 0.01689: 0.04,
% similarly the for loop that i tried did not work
%% everything else
c= 0 %7446; %Ns/m % assuming stiffness to be zero
V = 15.6464 %15.65; % Initial velocity of the Vehicle
Accel = (Accel/9.81); % converting acceleration into units of 'g-force'
%% simulating simulink model of differential equation
sim ('initial_mass_spring_damper')
%% Graphical outputs
subplot(221) %
plot(Time,Displ,'k','LineWidth',2); % plots given data
%etc creating other plots
MSD.PNG
Displ = Displacement(:,1);
Accel = Acceleration(:,1);
Forc = m*Accel;
subplot(221)
plot(Time,Displ,'g','LineWidth',2); % plot time displacement curve from the simulink model
hold on;
I would really appreciate any help or advice that anyone could give.

Answers (0)

Categories

Find more on General Applications in Help Center and File Exchange

Asked:

on 5 Apr 2019

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!