1

同じ図に複数のサブプロットをプロットしました。プロットの上にカーソルを移動すると、各サブプロットに「Datapoint」を手動で挿入するのではなく、各サブプロットから値を読み取りたいと思いました。

A=[1 2 3 4 5 6];
B=[3 4 5 6 2 8];
C=[3 2 7 5 8 3];
figure(1);
subplot(2,1,1);
plot(A,B,'m')
hold on;
subplot(2,1,2);
plot(A,C,':y')
Title('Test figure')

同じことをするためにMatlabに組み込み関数はありますか...ありがとう

4

2 に答える 2

0

ginputが探しているものかもしれません。

これが例です。うまくいけば、あなたが望むことをするためにそれを適応させることができます.

xData = 11:20;
data1 = rand(1, 10);
data2 = rand(1, 10);

ax1 = subplot(2, 1, 1);
plot(xData,data1)
hold on
ax2 = subplot(2, 1, 2);
plot(xData,data2)
hold on

[x,y] = ginput(1); % get one input point

% plot and label that point in the first subplot
axes(ax1)
plot(x, y, 'ro')
text(x, y, ['   x = ', num2str(x), 'y = ', num2str(y)])

% label that point in the second subuplot
axes(ax2)
plot(x, y, 'go')
text(x, y, ['   x = ', num2str(x), 'y = ', num2str(y)])
于 2013-10-30T14:58:01.893 に答える
0

あなたが探しているものを達成するために、フィギュアのプロパティWindowButtonMotionFunctionで -callbackを定義したいかもしれません。マウスを動かすたびにコールバックが発生し、(現在の軸の) マウス位置から、作成したデータ ビューアーを更新できます。currentPoint

あなたの読書の喜びのために、ここにヘルプからのヘルプWindowButtonMotionFunctionがあります:

WindowButtonMotionFcn
function handle | cell array containing function handle and additional arguments | string (not recommended)

Mouse motion callback function. Executes whenever you move the pointer within the figure window. Define the WindowButtonMotionFcn as a function handle. The function must define at least two input arguments (handle of figure associated with key release and an event structure).

See Function Handle Callbacks for information on how to use function handles to define the callback function.

Example Using All Window Button Properties

Click to view in editor — This example enables you to use mouse motion to draw lines. It uses all three window button functions.

Click to run example — Click the left mouse button in the axes and move the cursor, left-click to define the line end point, right-click to end drawing mode.
于 2013-10-30T15:44:43.160 に答える