How to plot a single variable function with constraints

10 visualizaciones (últimos 30 días)
Mihai Giurca
Mihai Giurca el 20 de Mzo. de 2020
Comentada: Huy Phan Dang el 19 de Jul. de 2021
Hello, I am trying to plot f(x) = 4 - x*sin(x) with constraints x>=6, x<=9 and log(x)>= -1. I tried using meshgrid but the graph came out wrong + it was in the 3rd dimension. Can anyone tell me how I should go about plotting a simple function with these constraints? Thank you!
  3 comentarios
Mihai Giurca
Mihai Giurca el 20 de Mzo. de 2020
I'm honestly not sure, my professor gave me these constraints and I'm not sure what the log is supposed to mean.
Huy Phan Dang
Huy Phan Dang el 19 de Jul. de 2021
log(x) or lg(x) can mean log 10 of x, my education system alway use lg(x) for log 10 of x as shortcut so it might be what your professor meant

Iniciar sesión para comentar.

Respuestas (2)

Ameer Hamza
Ameer Hamza el 20 de Mzo. de 2020
f = @(x) 4 - x*sin(x);
fplot(f, [6 9]);

Matt J
Matt J el 20 de Mzo. de 2020
Editada: Matt J el 20 de Mzo. de 2020
You can assign NaN to anything you don't want plotted. Example,
x=linspace(0,2,1000);
f=sin(x);
f( 0.5<=x & x<=1)=nan;
plot(x,f);

Categorías

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

Productos


Versión

R2019b

Community Treasure Hunt

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

Start Hunting!

Translated by