user interface - How to get a piecewise linear function in MATLAB GUI -


I want to implement the GUI in MATLAB 2010 that the user will be able to do interactive input (click and drag drag and Point to drop) is an implementation in C #

I hope there is a similar implementation in MATLAB which uses axes or any other object that captures the mouse event and breaks the pieces Updates to . Below are a few examples of user input in the form of a linear function:

image here Enter details  Enter image details here  Enter image details here  Enter image details here

addPoint.m on your path, save the M-file below and save the command Enter the line on the line T:

 & gt; & Gt; HFigure = shape; & Gt; & Gt; HAxes = axes ('guardian', hFigure); & Gt; & Gt; Set (hAxes, 'ButtonDownFcn', @addPoint);  

This creates an axis that will run addPoint every time it is clicked on the axes. If a line does not already exist, then addPoint creates a line, gets the coordinates of the clicked point, and these coordinates receive XData and The properties of YData combines the line. prefix function addPoint (hObject, eventdata)% get the clicked point CurrentPoint = get (hObject, 'CurrentPoint'); Meet the Handle Plotted Line Create a line if any% is not present HLine = get (hObject, 'child'); If Hamperi (Hline) HLEE = Line (0, 0, ... 'Parent', Hobbit, ... 'Marker', 'S', ... 'Marker Edgiorolor', 'R'); End% temporarily renewable units are generalized set axis units = get (Hobbit, 'units'); Set (hasbect, 'units', 'normalized'); Get% Clicked Point and Add it to the Plotted Line Data (:, 1) = get (Hline, 'xData'); Data (:, 2) = get (hiline, 'widata'); Data (end + 1, :) = [current page (1,1) current page (1,2)]; Data = sorted (data, 1); Set (hiline, 'xdata', data (:, 1), 'widata', data (:, 2)); % Set axis units reset set (hobcat, 'units', access units);

You can improve this by automatically updating the borders of the axes after the first click.

Comments