フィルターのクリア

Invalid expression during a function handle

24 ビュー (過去 30 日間)
Allen Yau
Allen Yau 2024 年 8 月 2 日 16:15
コメント済み: Allen Yau 2024 年 8 月 2 日 16:24
I am recieving the following error:
Invalid expression. Check for missing multiplication operator, missing or unbalanced delimiters, or other syntax error. To construct matrices, use brackets instead of parentheses.
This is the line that is causing the error:
Kernel = @x q.*(exp(-jk.*(sqrt(a^2 + (m1 - (x)).^2)))./(4*pi.*((sqrt(a^2 + (m1 - (x)).^2)).^5)))*((1+jk.*(sqrt(a^2 + (m1 - (x)).^2))).*(2*((sqrt(a^2 + (m1 - (x)).^2)).^2)-3.*(a^2))+((k*a.*(sqrt(a^2 + (m1 - (x)).^2))).^2));
The following variables have already been defined prior to this line:
q, jk, m1, k and a. The only variable is x.
I counted the parentheses, checked the multiplication operator, and I am not trying to construct a matrix.
Some background context:
This line is within 2 for loops. When I take off the function handle (@x) and set x = 1, the code runs without any errors. I plan on integrating this Kernel function and pass it to an array. The original equation is q*(exp(-jk*R)/(4*pi*(R^5)))*((1+jk*R)*(2*(R^2)-3*(a^2))+((k*a*R)^2)) but since the variable X is within R, I expanded R at each instance. R = sqrt(a^2 + (m1 - m2)^2)
Thank you guys in advance!

回答 (1 件)

Torsten
Torsten 2024 年 8 月 2 日 16:17
移動済み: Torsten 2024 年 8 月 2 日 16:18
Must read
Kernel = @(x) ...
instead of
Kernel = @x ...
  1 件のコメント
Allen Yau
Allen Yau 2024 年 8 月 2 日 16:24
Thank you! Cant believe it was just this

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

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by