- https://www.mathworks.com/help/matlab/ref/fill.html#mw_fe77d2a1-24b9-474d-8e5f-81afb7727192
- https://www.mathworks.com/help/matlab/ref/patch.html#buscm5g-1
How to draw a graph like the image attached below in MATLAB
조회 수: 2 (최근 30일)
이전 댓글 표시
Hello, experts.
I would like to draw the picture below using Matlab. What function can I use to plot it?
댓글 수: 0
답변 (2개)
VINAYAK LUHA
2024년 7월 8일
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
댓글 수: 0
Aquatris
2024년 7월 8일
편집: Aquatris
2024년 7월 8일
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
댓글 수: 0
참고 항목
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!