Borrar filtros
Borrar filtros

How to draw a graph like the image attached below in MATLAB

51 visualizaciones (últimos 30 días)
mertesacker
mertesacker el 8 de Jul. de 2024 a las 4:59
Editada: Aquatris el 8 de Jul. de 2024 a las 8:52
Hello, experts.
I would like to draw the picture below using Matlab. What function can I use to plot it?

Respuestas (2)

VINAYAK LUHA
VINAYAK LUHA el 8 de Jul. de 2024 a las 5:43
Hello Mertesacker,
To create a plot with a filled gradient color, you can use the MATLAB "patch" or the "fill" functions.
For implementation, you can refer to the examples provided in the documentation below:
Additionally, you might find this MATLAB Answers post helpful:
Best regards,
Vinayak Luha

Aquatris
Aquatris el 8 de Jul. de 2024 a las 8:51
Editada: Aquatris el 8 de Jul. de 2024 a las 8:52
You can also use countourf function;
% random data from countour example
x = linspace(-2*pi,2*pi);
y = linspace(0,4*pi);
[X,Y] = meshgrid(x,y);
Z = sin(X) + cos(Y);
% define the shape to color
xv = [-4 -6 0 4 2 -4];
yv = [2 10 12 10 2 2];
[in,on] = inpolygon(X,Y,xv,yv);
% set data outside of the shape to NaN
Z(~in) = NaN;
contourf(X,Y,Z,10)
colorbar

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by