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

조회 수: 1 (최근 30일)
Ruslan Aslanov
Ruslan Aslanov 2021년 11월 30일
답변: Voss 2021년 11월 30일
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

채택된 답변

Voss
Voss 2021년 11월 30일
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.

추가 답변 (0개)

제품


릴리스

R2020a

Community Treasure Hunt

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

Start Hunting!

Translated by