Still fairly new to MatLab, using this code, I am attempting to plot both the |Zo| and Mag (sqrt(L/C)) lines on the same graph. However it is only plotting the |Zo| line. I have also attemped to use hold on an off's, however only the one line is plotted.
% Constants
R = [2.2]; % ohm m^-1
L = [105]*1e-9; % H m^-1
C = [69]*1e-12; % F m^-1
G = [14]*1e-9; % S m^-1
% Frequency range
f = logspace(0,9); % Hz
% Propagation coefficient
alpha = sqrt((R + 1i*2*pi*f.*L).*(G + 1i*2*pi*f.*C));
beta = sqrt((R + 1i*2*pi*f.*L).*(G + 1i*2*pi*f.*C)) .* sqrt(G + 1i*2*pi*f.*C);
% Characteristic impedance
Zo = sqrt((R + 1i*2*pi*f.*L)./(G + 1i*2*pi*f.*C));
% Sqrt(L/C)
Mag = sqrt(L/C);
loglog(f, abs(Zo),f, Mag)
xlabel('Frequency (Hz)');
ylabel('|Z_o| (\Omega)');
title('Characteristic Impedance |\Z_o|');
grid on;

댓글 수: 1

Stephen23
Stephen23 2023년 3월 12일
편집: Stephen23 2023년 3월 12일
Compare:
L = [105]*1e-9; % two numbers and two operations
vs.
L = 105e-9; % one number
Only add complexity to code, if it does something useful. Obfuscation is not useful.

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

답변 (1개)

Walter Roberson
Walter Roberson 2023년 3월 12일
% Constants
R = [2.2]; % ohm m^-1
L = [105]*1e-9; % H m^-1
C = [69]*1e-12; % F m^-1
G = [14]*1e-9; % S m^-1
% Frequency range
f = logspace(0,9); % Hz
% Propagation coefficient
alpha = sqrt((R + 1i*2*pi*f.*L).*(G + 1i*2*pi*f.*C));
beta = sqrt((R + 1i*2*pi*f.*L).*(G + 1i*2*pi*f.*C)) .* sqrt(G + 1i*2*pi*f.*C);
% Characteristic impedance
Zo = sqrt((R + 1i*2*pi*f.*L)./(G + 1i*2*pi*f.*C));
% Sqrt(L/C)
Mag = sqrt(L/C);
loglog(f, abs(Zo), '-.', f, Mag, '-*')
xlabel('Frequency (Hz)');
ylabel('|Z_o| (\Omega)');
title('Characteristic Impedance |Z_o|');
grid on;
Why the line of * ? Answer: because Mag is a scalar, not a vector. L and C are scalars so sqrt(L/C) is a scalar.

카테고리

도움말 센터File Exchange에서 Images에 대해 자세히 알아보기

제품

릴리스

R2022a

태그

질문:

2023년 3월 12일

편집:

2023년 3월 12일

Community Treasure Hunt

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

Start Hunting!

Translated by