Borrar filtros
Borrar filtros

How do I go about plotting this function in MATLAB?

1 visualización (últimos 30 días)
Paul Chang
Paul Chang el 10 de En. de 2017
Respondida: Niels el 10 de En. de 2017
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].

Respuestas (1)

Niels
Niels el 10 de En. de 2017
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))

Categorías

Más información sobre Line Plots en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by