Graph appears blank but the equation and code are correct.

1 回表示 (過去 30 日間)
Nathan
Nathan 2022 年 9 月 23 日
コメント済み: Nathan 2022 年 9 月 23 日
Hi,
I'm graphing a Gaussian function that resembles the inverse impulse response, which should look like this:
However, the graph on matlab appears blank and I can't figure out the problem.
My code:
H_k_eq = @(k) (exp(-pi.*k.^2)) / (exp(-pi.*k.^2) + exp(-pi.*(4.*k).^2));
Range = -0.5:.01:0.5;
plot(Range,H_k_eq(Range))
What is wrong with my code?

採用された回答

Walter Roberson
Walter Roberson 2022 年 9 月 23 日
The MATLAB / operator is "matrix right division". A/B is similar to A * pinv(B) (but not exactly that.) So when you have a row vector on the left and the right of the / operator, MATLAB does what is effectively a fitting operation, returning a scalar result
H_k_eq = @(k) (exp(-pi.*k.^2)) ./ (exp(-pi.*k.^2) + exp(-pi.*(4.*k).^2));
Range = -0.5:.01:0.5;
plot(Range,H_k_eq(Range))

その他の回答 (1 件)

KSSV
KSSV 2022 年 9 月 23 日
H_k_eq = @(k) (exp(-pi.*k.^2)) ./ (exp(-pi.*k.^2) + exp(-pi.*(4.*k).^2)); %<-- element by element division
Range = -0.5:.01:0.5;
plot(Range,H_k_eq(Range))

カテゴリ

Help Center および File Exchange2-D and 3-D Plots についてさらに検索

タグ

製品


リリース

R2021b

Community Treasure Hunt

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

Start Hunting!

Translated by