Mapping 1D vector to 2D area
古いコメントを表示
load xPoints; load yPoints; j=boundary(xPoints,yPoints,0.1); Plot(xPoints(j),yPoints(j))

%How do I map the x-values to y-values here?
4 件のコメント
Prasanna Routray
2024 年 9 月 27 日
Rahul
2024 年 9 月 27 日
Hi @Prasanna Routray, it's not very clear from your question how you want to map the xPoints and yPoints data further. You've created a boundary plot for the data, and if in case, plotting the xPoints and yPoints on the same plot is what you want, you can try:
load xPoints; load yPoints; j=boundary(xPoints,yPoints,0.1);
plot(xPoints(j),yPoints(j),'LineWidth',1, 'Color','black');
hold on
plot(xPoints, yPoints);

Prasanna Routray
2024 年 9 月 27 日
Image Analyst
2024 年 9 月 27 日
What if, for a given vertical line (like you specified x with some specific value), there are no y values for that exact x value? Maybe some are close but not exact. Do you want to find all y values within a certain tolerance of your specified x? If so use ismembertol().
採用された回答
その他の回答 (1 件)
Rahul
2024 年 9 月 27 日
I believe that you're trying to want to obtain a reverse mapping, from xPoints data to yPoints data, using a MATLAB function. Here's how you can code the same:
function [res_x, res_y] = getYs(x, xPoints, yPoints)
x = 5;
n = size(xPoints, 1);
res_y = [];
res_x = [];
for i=1:n
if xPoints(i) == x
res_y = [res_y yPoints(i)];
res_x = [res_x x];
end
end
end
Use the above function to get yPoints values corresponding to a given 'x', plot the resultant values on the figure, and display the resultant array 'res_y':
load xPoints; load yPoints;
j=boundary(xPoints,yPoints,0.1);
plot(xPoints(j),yPoints(j), 'Color','black');
hold on;
% Call getYs to get corresponding y values for a given x = 5
x = 5;
[res_x, res_y] = getYs(x, xPoints, yPoints);
% Plot returned data using dotted red line on same graph
plot(res_x, res_y, 'r.');
disp(res_y);
hold off;

カテゴリ
ヘルプ センター および File Exchange で MATLAB Support Package for USB Webcams についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!



