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

조회 수: 3 (최근 30일)
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 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이전 댓글 -1개 표시이전 댓글 -1개 숨기기
Ammar 2024년 7월 18일
Thank You! This is what I needed.

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

카테고리

Help CenterFile Exchange에서 Calculus에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by