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