对于以下内容:
x = [0.5 1.5 2.5 3.5 4.5];
for k = 1:1:5
plot(x(k),x','b^','linewidth', 2)
hold on
end
如同:
[x,y] = meshgrid(0.5:1:4.5);
我如何索引每个点(蓝色三角形)坐标?
结果应该是这样的:
point1 = [x(1),x(1)]; % [0.5,0.5]
point2 = [x(1),x(2)]; % [0.5,1.5]
point3 = [x(1),x(3)]; % [0.5,2.5]
point4 = [x(1),x(4)]; % [0.5,3.5]
point5 = [x(1),x(5)]; % [0.5,4.5]
point6 = [x(2),x(1)]; % [1.5,0.5]
...
point25 = [x(5),x(5)];% [4.5,4.5]
我必须做错事,否则 matlab 程序今天不让我索引这些。
[~,idx] = length(point(:));
idxpoint = ind2sub(size(point),idx);
请写一个工作示例。
先感谢您。