Finding zeros of intersection of the "x-axis" - Error using "fzero"

3 ビュー (過去 30 日間)
Ammar
Ammar 2024 年 7 月 17 日
コメント済み: Ammar 2024 年 7 月 18 日
Hello,
I am currently facing an issue where I am trying to find the intersection of the different plots on my "x-axis" (horizontal axis).
I have tried using "fsolve" in MATLAB, but they've given me errors such as:
The input to FSOLVE should be either a structure with valid fields or consist of at least two arguments.
For the solve function, it says:
Unable to find explicit solution
See MATLAB code attached:
Zeros_k_p.m
I've tried to use the "solve" function in MATLAB but I just end up getting an empty val ==> Empty sym: 0-by-1
Essentially, I have an equation called "T_M" that has a variable "k_p". I need to find where the equation "T_M" crosses the "x-axis" and find all of the roots for "k_p".
tic
close all; clc;
% For the region k_o < k_p < sqrt(u_r*e_r)*k_o
% Specifying k_p as a symbolic object using the symbolic toolbox
syms k_p;
% Wavelength value lambda
lambda = 1;
% Wavenumber in free space value = k_o
k = (2*pi)/lambda;
% Permeability Value = u_r
u_r = 1;
% Permittivity Value e_r
e_r = 2.2;
% Value of kz_1
kz_1 = sqrt((k)^2*e_r*u_r - (k_p)^2);
% Value of kz_2
kz_2 = sqrt((k_p)^2 - (k)^2);
% Substrate heights = d
d = [0.02 0.04 0.06 0.08 0.10];
% Equations for TM(kp)
T_M = kz_1.*sin(d.*kz_1) - e_r*sqrt(kz_2).*cos(d.*kz_1);
fplot(T_M,[k k*sqrt(e_r*u_r)], 'LineWidth',3);
ylim([-5 5]);
xlim([k k*sqrt(e_r*u_r)]);
grid on;
ax = gca;
ax.GridLineWidth = 2;

採用された回答

Matt J
Matt J 2024 年 7 月 18 日
編集済み: Matt J 2024 年 7 月 18 日
tic
close all; clc;
% For the region k_o < k_p < sqrt(u_r*e_r)*k_o
% Wavelength value lambda
lambda = 1;
% Wavenumber in free space value = k_o
k = (2*pi)/lambda;
% Permeability Value = u_r
u_r = 1;
% Permittivity Value e_r
e_r = 2.2;
% Value of kz_1
kz_1 =@(kp) sqrt((k).^2*e_r*u_r - (kp).^2);
% Value of kz_2
kz_2 = @(kp) sqrt((kp).^2 - (k).^2);
% Substrate heights = d
D = [0.02 0.04 0.06 0.08 0.10];
for i=1:numel(D)
d=D(i);
% Equations for TM(kp)
T_M = @(kp) kz_1(kp).*sin(d.*kz_1(kp)) - e_r*sqrt(kz_2(kp)).*cos(d.*kz_1(kp));
kp_root=fzero(T_M, [k , k*sqrt(e_r*u_r)])
fplot(T_M,[k k*sqrt(e_r*u_r)], 'LineWidth',3); hold on
plot(kp_root,0,'o','MarkerSize',8,'MarkerFaceColor','k');
ylim([-5 5]);
xlim([k k*sqrt(e_r*u_r)]);
grid on;
ax = gca;
ax.GridLineWidth = 2;
end; hold off
kp_root = 6.2860
kp_root = 6.3292
kp_root = 6.4978
kp_root = 6.8051
kp_root = 7.1518
  1 件のコメント
Ammar
Ammar 2024 年 7 月 18 日
Thank You! This is what I needed.

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeCalculus についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by