How do I go about plotting this function in MATLAB?

1 回表示 (過去 30 日間)
Paul Chang
Paul Chang 2017 年 1 月 10 日
回答済み: Niels 2017 年 1 月 10 日
smys x; smys y; f = (1 / 2*pi*sqrt(3)) * exp((4*x*x - 8*x + y*y + 2*x*y - 2*y + 4) / 3); plot(f);
It is just going to be on an x-y plane with a range of [-3, 3] and a domain of [-3, 3].

回答 (1 件)

Niels
Niels 2017 年 1 月 10 日
Hi Paul,
first of all, there is no need to use syms if you just want to create a function.
you can use function handle and create an anonymus function: (in addition i think you got something wrong in your function, or it wont do as you desire
look at
(1 / 2*pi*sqrt(3)) = 1/2 * pi * sqrt(2)
i guess you want
1 / (2*pi*sqrt(3)) = 1/2 / pi / sqrt(2)
create the function f(x,y), the dots are necessary (read about function handles and anonymous functions
f = @(x,y) 1 ./ (2*pi.*sqrt(3)) .* exp((4*x.*x - 8*x + y.*y + 2*x.*y - 2*y + 4) ./ 3);
now you need to set the interval in which the function shall be plotted
x=linspace(Start,End,NumberOfPoints);
y=linspace(Start,End,NumberOfPoints);
plot(x,y,f(x,y))

カテゴリ

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

Community Treasure Hunt

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

Start Hunting!

Translated by