Asked by Serena Solanki
on 19 Feb 2018

Essentially I didn't know how to ask this as it probably is simple but I don't quite know what to do.

Essentially I want to create a response function for an earthquake record, where ultimately I want to plot the peak displacement against a varying time period. I am using the Runge-Kutta Method to integrate to get displacement from the acceleration data.

I have got a range of values for the time period -T0 and have calculated the state-space matrix A from this.

essentially I am unsure if i need to interpolate my A matrix to be the same size as my Npts in order for the loop to work.

Hope it makes sense and hope you can help!

Thanks in advance!!

for i=0.1:0.1:4; % Range of Time Periods defined

T0=(i);% seconds

w = (2*pi)/T0(1:end); %rad/s

w2=w(1:end)*w(1:end);

zita=0.05;

m=773; % Mass in MG

A1=[0 1

-w2(1:end) -(2*zita*w(1:end))]; %state-space matrix of coefficients

b=[0

1/m]; %state-space load vector

end

ft = m*acc.'; %acceleration data- converting to force f=ma

dt = 0.02; %seconds

NPTS = size(ft); %no.of points

tf = (NPTS-1)*dt;

t = 0:dt:tf;

A=A1(1:end);

dt_interp = 0.0001;

t_interp = dt_interp:dt_interp:tf;

ft_interp = F_interp(t, ft, t_interp);

NPTS_interp = size(t_interp,2);

yt = zeros(2,t_interp);

for i=1:(NPTS_interp-1)% Runge-Kutta loop, i = incremental time step

g1 = A(1:end)*yt(:,i)+b*ft_interp(i);

g2 = A(1:end)*(yt(:,i)+ 0.5*g1*dt_interp)+0.5*b*(ft_interp(i)+ft_interp(i+1));

g3 = A(1:end)*(yt(:,i)+ 0.5*g2*dt_interp)+0.5*b*(ft_interp(i)+ft_interp(i+1));

g4 = A(1:end)*(yt(:,i)+g3*dt_interp)+b*ft_interp(i+1);

ynew = yt(:,i)+(g1+2*g2+2*g3+g4)*dt_interp/6;

yt(:,i+1)=ynew; %storage

ut=yt(1,:); %displacement values

vt=yt(2,:);%velocity values

[pks,locs]=findpeaks(ut,t_interp);

Max_displacement=max(pks);

end

Opportunities for recent engineering grads.

Apply Today
## 5 Comments

## Bob Nbob (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/383581-how-to-interpolate-a-matrix#comment_537059

## Serena Solanki (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/383581-how-to-interpolate-a-matrix#comment_537064

## Bob Nbob (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/383581-how-to-interpolate-a-matrix#comment_537093

## Stephen Cobeldick (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/383581-how-to-interpolate-a-matrix#comment_537188

## Serena Solanki (view profile)

## Direct link to this comment

https://www.mathworks.com/matlabcentral/answers/383581-how-to-interpolate-a-matrix#comment_537537

Sign in to comment.