爲以下幾點:Matlab的:指數5×5網格點
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);
請寫一個工作示例。
預先感謝您。
很抱歉,但我不明白你的問題。一個完全盲目的猜測,如果沒有完全理解你的問題,我會說你應該看看重塑。 – 2012-11-27 18:58:26