- imagesc: https://www.mathworks.com/help/matlab/ref/imagesc.html
- scatter: https://www.mathworks.com/help/matlab/ref/scatter.html
Plot 2D predicate function
조회 수: 2 (최근 30일)
이전 댓글 표시
I have a preducate function f(x, y) which returns a logical value (ie. it returns true iff (x, y) is in the set of points described by f).
I would like to plot it. I want a 2D plot where the color of the points for which f returns true is colored.
I've tried to use fcontour, but it often creates incorrect plots and I suspect it assumes some kind of smoothness of my predicate.
댓글 수: 0
답변 (1개)
Jaynik
2024년 4월 4일
Hi Gergely,
Instead of using 'fcontour', you can use the 'imagesc' function which takes the input as "x", "y" and instead of "C", you can give the output of your predicate function "f".
You can also use any other plot by obtaining the "x" and "y" indices where "f" is true and plotting them. For example, following is sample code that uses a 'scatter plot':
Z = f(X, Y);
% Using imagesc to create a 2D plot:
% imagesc(x, y, Z);
[trueY, trueX] = find(Z);
scatterX = x(trueX);
scatterY = y(trueY);
% Scatter plot for points where x and y are true:
scatter(scatterX, scatterY, 1, 'filled');
Please refer to the following documentation to know more about these functions:
Hope this helps!
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Labels and Styling에 대해 자세히 알아보기
제품
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!