Can you explain to me the last part of this code? Thanks in advance!

2 views (last 30 days)
close all
clear all
%properties of rocks
Vs_soil=170;
Psoil=1.5;
Hs=70;
Vs_rock=1000;
Prock=2.4;
damp=0;
%impedance ratio
IC=((Prock*Vs_rock)/(Psoil*Vs_soil));
%Ground fundamental frequency
f0=Vs_soil/(4*Hs);
%Maximum magnification for one dimensional monolayer
A0=1/((1/IC)+0.5*pi*damp);
%harmonic frequencies
d=10;
dx=1/d;
n=-0.5:dx:8;
fn=(2*n+1)*f0;
%Magnification / Resonant frequency
% I didn't get this part of the code after "a=cos(w*Hs/Vs_soil)". Why are " round, isinf " used here?
w=2*pi*fn;
a=cos(w*Hs/Vs_soil);
y=roundn(a,-4);
Fw=1./abs(y);
Fw(isinf(Fw))=A0;
%Let's draw the magnification graph
plot(fn,Fw);
title('magnification graph');
xlabel('f(Hz)');
ylabel('Magnification F(w)');
legend('Transfer Function');
grid;
print -djpeg magnification graph

Accepted Answer

Voss
Voss on 30 Nov 2021
y=roundn(a,-4);
rounds a to the nearest multiple of 10^-4 and stores the result in y.
Fw(isinf(Fw))=A0;
replaces elements of Fw that are Inf or -Inf with A0.

More Answers (0)

Categories

Find more on Graphics Performance in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!