datacursormode callback / inserting cursors

6 visualizaciones (últimos 30 días)
Bjoern Hackert
Bjoern Hackert el 28 de Feb. de 2019
Hello all
I have a GUI which includes several tabs and several axis.
On one axis, I'm plotting several curves like this (note that this procedure is saved in an extra script file and is called from the main file)
axes(handles.axis_zoom);
satellite = 'glo';
prnarray = handles.prnarray;
for k=1:length(prnarray)
temp_data = handles.data.(strcat(satellite, num2str(prnarray(k))));
L(k) = plot(handles.meas_time, temp_data, '-b', 'linewidth', 1);
end
Then, credits to https://de.mathworks.com/matlabcentral/answers/1308-cursor-line, I will add multiple cursors like this
hold on;
for ii = 1:length(prnarray)
S.D{ii} = get(L(ii),{'xdata','ydata'});
S.L(ii) = length(S.D{ii}{1});
S.M(ii) = floor(S.L(ii)/2);
S.DF = diff(S.D{ii}{1}(S.M(ii):S.M(ii)+1)); % uniform assum
S.I(ii) = S.M(ii);
S.T(ii) = text(S.D{ii}{1}(S.M(ii)+2),S.D{ii}{2}(S.M(ii)+2),'here');
set(S.T(ii),'string',{['Y: ',sprintf('%3.3g',S.D{ii}{2}(S.M(ii)))]})
S.F(ii) = plot(S.D{ii}{1}(S.M(ii)),S.D{ii}{2}(S.M(ii)),'sk');
set(S.F(ii),'markerfacec','b')
end
This will plot me the y values of each plot in the middle of the x axis.
Now i want to move along the x axis so I can inspect the datapoints.
I tried a callback on the axis
function axis_zoom_ButtonDownFcn(hObject, eventdata, handles)
S.D{ii} = get(handles.axis_zoom,{'xdata','ydata'});
But this simply never triggers, I dont know why, also I am not sure if this syntax will read the x and y data from all the plots ( would be nice to know how to get the data from a certain plot by the way), but as i said it doesnt trigger.
I am pretty new to Matlab and don't know how to integrate an updatefunction, also most examples I could google were in one simple script, if possible, where do I set it (main script or the sub script which plottes the data).
I guess i could handle to get the x coordinate from the datacursor, but main problem at this moment is the triggering, is there a datacursor trigger event i can use?
Thanks

Respuestas (0)

Categorías

Más información sobre 2-D and 3-D Plots en Help Center y File Exchange.

Productos


Versión

R2018b

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by