Keep elements of an array that only fall within a given closed shape
显示 更早的评论
Hello everyone
I have the following two vectors defined in my system:
space_a=linspace(0,168.3934962848858,500); % nm
space_b=linspace(0,250,500); % nm
In addition, I have a 500x500 matrix where each element contains a numerical value. The (1,1) element of this array corresponds to the value at space_a=0 and space_b=0, while the (500,500) element corresponds to the value at space_a=168.3934962848858 and space_b=250. If I plot my data, I have something like this:

My goal is, maintaining the fact that my matrix is a 500x500 array, only to preserve the original numerical value of those array elements that are inside the closed shape drawn on top of the figure through a solid black line. The coordinates of the four vertices of that shape are given by (first column: a-th dimension in nm, second column: b-th dimension in nm):
0*max(space_a) 0.45346624100816*max(space_b)
0.545581275830418*max(space_a) 1*max(space_b)
1*max(space_a) 0.54653375899184*max(space_b)
0.454418724169582*max(space_a) 0*max(space_b)
Any idea on how I can accomplish this while maintaining the fact that it is a 500x500 matrix, with the elements of the matrix outside the closed shape being equal to 0?
采纳的回答
更多回答(0 个)
类别
在 帮助中心 和 File Exchange 中查找有关 Creating and Concatenating Matrices 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!
