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 日

0 投票

% 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 ExchangeImages についてさらに検索

製品

リリース

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