日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

MATLAB+GUI:手动修改曲线中的点

發布時間:2023/12/8 编程问答 30 豆豆
生活随笔 收集整理的這篇文章主要介紹了 MATLAB+GUI:手动修改曲线中的点 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

本文目的:手動修改已知曲線中的點
功能:
1、可以放縮圖像,進行數據點的修改
2、可以選定數據點,并進行修改
3、數據點的修改不能超出相鄰點的范圍
4、可以移動坐標軸和圖像,以方便觀察整體圖像
5、可以保存修改后的數據
本代碼可以自行下載:https://download.csdn.net/download/qq_27261889/10577901

function varargout = movePoints(varargin) % MOVEPOINTS MATLAB code for movePoints.fig % MOVEPOINTS, by itself, creates a new MOVEPOINTS or raises the existing % singleton*. % % H = MOVEPOINTS returns the handle to a new MOVEPOINTS or the handle to % the existing singleton*. % % MOVEPOINTS('CALLBACK',hObject,eventData,handles,...) calls the local % function named CALLBACK in MOVEPOINTS.M with the given input arguments. % % MOVEPOINTS('Property','Value',...) creates a new MOVEPOINTS or raises the % existing singleton*. Starting from the left, property value pairs are % applied to the GUI before movePoints_OpeningFcn gets called. An % unrecognized property name or invalid value makes property application % stop. All inputs are passed to movePoints_OpeningFcn via varargin. % % *See GUI Options on GUIDE's Tools menu. Choose "GUI allows only one % instance to run (singleton)". % % See also: GUIDE, GUIDATA, GUIHANDLES% Edit the above text to modify the response to help movePoints% Last Modified by GUIDE v2.5 29-Jul-2018 04:49:24% Begin initialization code - DO NOT EDIT gui_Singleton = 1; gui_State = struct('gui_Name', mfilename, ...'gui_Singleton', gui_Singleton, ...'gui_OpeningFcn', @movePoints_OpeningFcn, ...'gui_OutputFcn', @movePoints_OutputFcn, ...'gui_LayoutFcn', [] , ...'gui_Callback', []); if nargin && ischar(varargin{1})gui_State.gui_Callback = str2func(varargin{1}); endif nargout[varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); elsegui_mainfcn(gui_State, varargin{:}); end % End initialization code - DO NOT EDIT% --- Executes just before movePoints is made visible. function movePoints_OpeningFcn(hObject, eventdata, handles, varargin) % This function has no output args, see OutputFcn. % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % varargin command line arguments to movePoints (see VARARGIN)% Choose default command line output for movePoints handles.output = hObject;% Update handles structure guidata(hObject, handles);% UIWAIT makes movePoints wait for user response (see UIRESUME) % uiwait(handles.figure1);% --- Outputs from this function are returned to the command line. function varargout = movePoints_OutputFcn(hObject, eventdata, handles) % varargout cell array for returning output args (see VARARGOUT); % hObject handle to figure % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA)% Get default command line output from handles structure varargout{1} = handles.output;% --- Executes on button press in pushbutton1. function pushbutton1_Callback(hObject, eventdata, handles) % hObject handle to pushbutton1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global xData yData xData = textread('xData.txt'); yData = textread('yData.txt'); drag_point(hObject, eventdata, handles)% --- Executes on button press in pushbutton2. function pushbutton2_Callback(hObject, eventdata, handles) % hObject handle to pushbutton2 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) zoom on;% --- Executes on button press in pushbutton3. function pushbutton3_Callback(hObject, eventdata, handles) % hObject handle to pushbutton3 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) zoom off;function drag_point(hObject, eventdata, handles) global xData yData hl hp flag flag = 0; hl = line(xData, yData); axes(handles.axes1); distance = max(xData) - min(xData); factor = 0.05; axis([min(xData)-distance*factor, max(xData)+distance*factor , min(yData)-distance*factor, max(yData)+distance*factor]); for i = numel(xData):-1:1hp(i) = patch('xdata',xData(i),'ydata',yData(i),...'linestyle','none','facecolor','none',...'marker','o','markerEdgecolor','k',...'markersize', 3, ...'buttonDownFcn',@drag,'userdata',i); endfunction drag(src, ~) global index of index = get(src,'userdata'); of = get(gcbf,{'WindowButtonMotionFcn','WindowButtonUpFcn'}); set(gcbf,'WindowButtonMotionFcn',@move,'WindowButtonUpFcn',@drop);function move(~, ~) global index points hl hp xData points = get(gca,'currentPoint'); xn = points(1); yn = points(3); if index>1 && index<size(xData,2)if xn<hl.XData(index-1)xn = hl.XData(index-1);endif xn>hl.XData(index+1)xn = hl.XData(index+1);endif yn<hl.YData(index-1)yn = hl.YData(index-1);endif yn>hl.YData(index+1)yn = hl.YData(index+1);end end set(hp(index),'xdata',xn,'ydata',yn) hl.XData(index) = xn; hl.YData(index) = yn;function drop(src,~) global of set(src,'WindowButtonMotionFcn',of{1},'WindowButtonUpFcn',of{2});% --- Executes on button press in pushbutton4. function pushbutton4_Callback(hObject, eventdata, handles) % hObject handle to pushbutton4 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) global xData yData flag flag = 1; dlmwrite('newX.txt',xData) dlmwrite('newY.txt',yData)% --- Executes on mouse press over axes background. function axes1_ButtonDownFcn(hObject, eventdata, handles) % hObject handle to axes1 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) % axes(handles.axes1); % zoom on global flag if flag==1drag_point(hObject, eventdata, handles); end% --- Executes on button press in pushbutton5. function pushbutton5_Callback(hObject, eventdata, handles) % hObject handle to pushbutton5 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) axes(handles.axes1); positionX = get(gca, 'xlim'); % positionY = get(gca, 'ylim'); factor = 0.1; positionX = positionX - factor * (positionX(2)-positionX(1)); set(gca, 'xlim', [positionX(1), positionX(2)]); % set(gca, 'ylim', [positionY(1), positionY(2)]);% --- Executes on button press in pushbutton6. function pushbutton6_Callback(hObject, eventdata, handles) % hObject handle to pushbutton6 (see GCBO) % eventdata reserved - to be defined in a future version of MATLAB % handles structure with handles and user data (see GUIDATA) axes(handles.axes1); positionX = get(gca, 'xlim'); % positionY = get(gca, 'ylim'); factor = 0.1; positionX = positionX + factor * (positionX(2)-positionX(1)); set(gca, 'xlim', [positionX(1), positionX(2)]);

結果展示


總結

以上是生活随笔為你收集整理的MATLAB+GUI:手动修改曲线中的点的全部內容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網站內容還不錯,歡迎將生活随笔推薦給好友。