2014-11-05 31 views
0

假設我的GUI(帶導向設計)自動升級這樣一個情節:繪製圓的時候,我們不得不排隊情節改善MATLAB R2014b

enter image description here

我想有圓形或類似的東西在改進措施:

enter image description here

如何,我們可以在MATLAB R2014b做到這一點?

PS。

我用這樣的代碼在GUI更新的情節:

plot(handles.plot,Value); %%(In a loop) 

Value的循環更新。

+1

數據如何看起來像你繪製的?你能提供生成劇情的部分代碼嗎? – hitzg 2014-11-05 10:37:06

+0

@hitzg我添加更多信息。 – user2991243 2014-11-05 10:41:07

+0

@ user2991243那麼任何答案都可以幫助您解決問題?如果是這樣,請將其標記爲已接受。謝謝! – 2014-11-07 14:01:04

回答

1

你可以做下面的檢測點,其中函數「提高」,即當導數的變化,並在相應的位置繪出點:

clear 
close all 
clc 


%// Generate dummy data 
t = 1:10; 
y = zeros(size(t)); 

idx1 = 0 <= t & t <= 2; 
y(idx1) = 2*t(idx1); 

idx2 = 2 < t & t < 3; 
y(idx2) = t(idx2); 

idx3 = 3 <= t & t <= 5; 
y(idx3) = 4; 

idx4 = 5 <= t & t <= 8; 
y(idx4) = 2*t(idx4); 

idx5 = 8 <= t & t <= 10; 
y(idx5) = 8; 
%====== 

%// Get indices corrsponding to change in curve 
CircleIndices = t(diff(diff(y)) ~= 0) +1 

%// Get y-coordinates 
yC = y(CircleIndices) 

%// plot the curve + the circles 
plot(t,y,'r') 
hold on 
scatter(CircleIndices,yC,40,'k','filled') 
hold off 

,看起來像這樣:

enter image description here

這是很容易在你的循環/回調來實現。希望有所幫助!

1

如果你想有過每一個數據點的圓請執行以下操作:

h = plot(handles.plot,Value,'.-'); 
set(h,'MarkerSize',20,'MarkerEdgeColor',[0 0 0]); 

第二線將設置點的大小和顏色,實驗給他們你想要的大小。

如果你想在一些特定的數據點繪製點做到這一點:

plot(handles.plot,Value); 
hold on 
h = plot(specific_X,specific_Y,'.'); 
set(h,'MarkerSize',20,'MarkerEdgeColor',[0 0 0]); 

其中specific_X和specific_Y與要繪製的點的數據點的X和Y向量。

1

@R。如果你已經知道了理想的點,Schifini寫了一個很好的答案。這個答案會很好,如果你想自動:

我知道你可以迭代地在循環內部的圖中添加數據(但是看起來你真的只是跑過前面的圖......)。如果是這樣,你可以寫這樣的:

plot(handles.plot,Value); %%(In a loop) 
if (Value(end)-Value(end-1))~=(Value(end-1)-Value(end-2)) %% if the slope is changing 
    hold on; plot(handles.plot(end-1),Value(end-1), 'ko','Markersize',15); 
end