I cant get the correct plotting

조회 수: 8 (최근 30일)
Abdullah Alsayegh
Abdullah Alsayegh 2023년 3월 28일
댓글: Torsten 2023년 3월 28일
I am trying to acheive a specfic graph but the code is not giving me the correct respond needed. The equations are correct but not giving the specfic values needed. I assume its an issue with the loop.
% Given
p = 7500; % kg/m^3
Cd33 = 16*10^10; %N/m^2
vp= 4620; % Ns/m
Ceb = 1.43E-9; % F
phi = 2.62; % As/m
% Piezoelectric Disk Material
dia = 12e-3;
radius = dia/2;
A = pi*radius^2;
tp = 1e-3;
% Water properies for mathcing layer
pw = 1000;
cw = 1500;
vm = 3000;
f0 = vp/4*tp;
tm = vm/4*f0;
% Frequency range
f = linspace(100e3, 2.2e6,200);
alpha = 1;
% Impedence
Rrad = pw*cw*A;
Z0p = 3920; % Ns/m
% frequency range
v0e = zeros(length(f),length(alpha));
% Loop Start
for i = 1:length(alpha)
for j = 1:length(f)
w = 2*pi*f(j);
km = w/vm;
kp = w/vp;
Z0m = alpha*Rrad;
Zcem = phi^2/1j*w*Ceb;
Zm1 = 1j*Z0m*tan(km*tm/2);
Zm2 = Z0m/(1j*sin(km*tm));
Zp1 = 1j*Z0p*tan(kp*tp/2);
Zp2 = Z0p/(1j*sin(kp*tp));
Z = [Zm1+Zm2+Rrad, -Zm2, 0;
-Zm2, Zp1+Zp2+Zm1+Zm2, -Zcem;
0, -Zcem, Zcem];
v0e(j) = phi*[1 0 0]*Z^-1*[0;0;1];
end
v0e(:,i) = v0e(j);
end
figure(1)
semilogy(f, abs(v0e),'linewidth', 2)
xlabel('Frequency [Hz]', 'fontsize', 15)
ylabel('Magnitude [Ns/m]', 'fontsize', 15)
grid on
figure(2)
plot(f, (180/pi)*v0e ,'linewidth', 2)
xlabel('Frequency [Hz]', 'fontsize', 15)
ylabel('phase [deg]', 'fontsize', 15)
grid on

채택된 답변

Torsten
Torsten 2023년 3월 28일
편집: Torsten 2023년 3월 28일
% Given
p = 7500; % kg/m^3
Cd33 = 16*10^10; %N/m^2
vp= 4620; % Ns/m
Ceb = 1.43E-9; % F
phi = 2.62; % As/m
% Piezoelectric Disk Material
dia = 12e-3;
radius = dia/2;
A = pi*radius^2;
tp = 1e-3;
% Water properies for mathcing layer
pw = 1000;
cw = 1500;
vm = 3000;
f0 = vp/4*tp;
tm = vm/4*f0;
% Frequency range
f = linspace(100e3, 2.2e6,200);
alpha = 1;
% Impedence
Rrad = pw*cw*A;
Z0p = 3920; % Ns/m
% frequency range
v0e = zeros(length(f),length(alpha));
% Loop Start
for i = 1:length(alpha)
for j = 1:length(f)
w = 2*pi*f(j);
km = w/vm;
kp = w/vp;
Z0m = alpha(i)*Rrad;
Zcem = phi^2/1j*w*Ceb;
Zm1 = 1j*Z0m*tan(km*tm/2);
Zm2 = Z0m/(1j*sin(km*tm));
Zp1 = 1j*Z0p*tan(kp*tp/2);
Zp2 = Z0p/(1j*sin(kp*tp));
Z = [Zm1+Zm2+Rrad, -Zm2, 0;
-Zm2, Zp1+Zp2+Zm1+Zm2, -Zcem;
0, -Zcem, Zcem];
v0e(j,i) = phi*[1 0 0]*Z^-1*[0;0;1];
end
end
figure(1)
semilogy(f, abs(v0e),'linewidth', 2)
xlabel('Frequency [Hz]', 'fontsize', 15)
ylabel('Magnitude [Ns/m]', 'fontsize', 15)
grid on
figure(2)
plot(f, (180/pi)*v0e ,'linewidth', 2)
Warning: Imaginary parts of complex X and/or Y arguments ignored.
xlabel('Frequency [Hz]', 'fontsize', 15)
ylabel('phase [deg]', 'fontsize', 15)
grid on
  댓글 수: 2
Abdullah Alsayegh
Abdullah Alsayegh 2023년 3월 28일
How to fix the error " Warning: Imaginary parts of complex X and/or Y arguments ignored."
Torsten
Torsten 2023년 3월 28일
I guess voe is complex-valued. And MATLAB does not like to plot complex values against real values. Thus it only plots the real part of 180/pi*voe against f.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Multirate Signal Processing에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by