I need to plot the following script. But it gives an error.
2 次查看(过去 30 天)
显示 更早的评论
I think the problem is that we can't divide 1 by 0 so the column "Fw=1/(cos(w*Hs/Vs_soil));" gives an error.
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:5.4;
fn=(2*n+1)*f0;
%Magnification / Resonant frequency
w=2*pi*fn;
Fw=1/(cos(w*Hs/Vs_soil));
%Let's draw the magnification graph
plot(fn,Fw);
title('magnification graph');
xlabel('f(Hz)');
ylabel('magnification F(w)');
legend('Transfer Function');
0 个评论
采纳的回答
VBBV
2021-11-28
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:5.4;
fn=(2*n+1)*f0;
%Magnification / Resonant frequency
w=2*pi*fn;
Fw=1./(cos(w*Hs/Vs_soil));
%Let's draw the magnification graph
plot(fn,Fw);
title('magnification graph');
xlabel('f(Hz)');
ylabel('magnification F(w)');
legend('Transfer Function');
use the element wise matrix operator
更多回答(1 个)
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!