1. 程式人生 > >MATLAB+GUI:手動修改曲線中的點

MATLAB+GUI:手動修改曲線中的點

本文目的:手動修改已知曲線中的點
功能:
1、可以放縮影象,進行資料點的修改
2、可以選定資料點,並進行修改
3、資料點的修改不能超出相鄰點的範圍
4、可以移動座標軸和影象,以方便觀察整體影象
5、可以儲存修改後的資料
由於不僅需要程式碼,還需要fig和資料等,可以私信索取。

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}); end if nargout [varargout{1:nargout}] = gui_mainfcn(gui_State, varargin{:}); else gui_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:1 hp(i) = patch('xdata',xData(i),'ydata',yData(i),... 'linestyle','none','facecolor','none',... 'marker','o','markerEdgecolor','k',... 'markersize', 3, ... 'buttonDownFcn',@drag,'userdata',i); end function 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); end if xn>hl.XData(index+1) xn = hl.XData(index+1); end if yn<hl.YData(index-1) yn = hl.YData(index-1); end if 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==1 drag_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手動修改曲線中的點

本文目的:手動修改已知曲線中的點 功能: 1、可以放縮影象,進行資料點的修改 2、可以選定資料點,並進行修改 3、資料點的修改不能超出相鄰點的範圍 4、可以移動座標軸和影象,以方便觀察整體影象 5、可以儲存修改

Android修改包名 方法一Rename方法,手動修改

下面介紹在Android studio中手動修改包名的方法: 1、點選 工程結構旁邊的小齒輪,將紅色部分那一串字元前的對勾去掉。 變化之後的結構為 2、在想要修改的那個包層級上 右鍵

手動修改PE檔案新增自定義程式碼

在PE檔案裡有很多位置可以新增自己的程式碼(其實就是感染PE),凡是用不到的地方都能加。想到的位置有(在檔案中不是在記憶體中):Dos頭和Nt頭之間、每個節末尾的Padding(間隙)、新增節分配在檔案末尾的空間;其它覆蓋資料的方法不安全容易引起錯誤還是算了。新增後還要在程

matlab錯誤Subscript indices must either be real positive integers or logicals.

開始 dice int 索引 cal ger 向量 過程 ice matlab錯誤:Subscript indices must either be real positive integers or logicals. 中文解釋:下標索引必須是正整數類型或者邏輯類型

手動修改MAC地址可以突破IP-MAC綁定嗎?

ip 管理 上網行為 這個世界有矛就有盾,既然有IP-MAC綁定的技術,總歸就有人會嘗試去突破這個綁定。一般來說,無非是通過”修改IP地址“和”修改MAC地址“兩種方式。1. IP地址的修改很簡單,在“本地連接”裏面,修改TCP/IP的屬性就可以,如圖:2. 大多數人不知道,其實電腦還可以修改“M

手動修改PHP頁面返回狀態碼

pre nbsp clas spa http style sta div code <?php //比如當前頁面要返回404狀態碼 header("HTTP/1.1 404 Not Found"); header("Status: 404 Not Found

xgene之ROC曲線、ctDNA、small-RNA seq、甲基化seq、單細胞DNA, mRNA

會有 模板 pat 活動 fff 1.5 科學家 因子 染色 靈敏度高 == 假陰性率低,即漏檢率低,即有病人卻沒有發現出來的概率低。 用於判斷:有一部分人患有一種疾病,某種檢驗方法可以在人群中檢出多少個病人來。 特異性高 == 假陽性率低,即錯把健康判定為病人的概率低

mybatis批量更新兩種方式1.修改值全部一樣 2.修改每條記錄值不一樣

nic mis str link eba encoding type 配置 tails Mybatis批量更新數據 mybatis批量更新兩種方式:1.修改值全部一樣 2.修改每條記錄值不一樣 mybatis批量更新兩種方式:

asp.net站點時間格式與系統時間格式不一致。手動修改

images 開始 iis 時間格式 重啟 .com short 技術分享 control asp.net站點時間格式與系統時間格式不匹配時,當修改系統時間格式,站點時間可能還是舊的格式。則可通過修改註冊表更新時間格式。1.開始-運行-輸入regedit,依次找到HKEY-

vuex-第3節Mutations修改狀態

spa 文件 喜歡 按鈕 div 通過 hub 調用 str 上節課我們學習了怎麽樣讀取state,那今天我們學習一下怎麽樣修改狀態。這個常量我們在第一節課的時候也碰到過,並且進行了加減的操作。那這節課我們就具體學習一下,如何操作Mutations。 $store.comm

GUIGUI的方式創建/訓練/仿真/預測神經網絡—Jason niu

9.png 分享圖片 image strong import 按鈕 底部 gpo body (1)導入數據:點擊最左底部Import 按鈕 (2)創建模型network_Jason_niu:點擊底部的New按鈕 (3)設置參數並訓練:點擊底部的Open按鈕

[學習一個] Matlab GUI 學習筆記 Ⅰ

blank 技術分享 提問 string 自學 水平 crop AD pin Matlab GUI 學習筆記 Ⅰ 1. Foreword Matlab 是嚴格意義上的編程語言嗎?曾經有人告訴我他是通過 Matlab 學會了面對對象編程,我是不信的,但這依然不妨礙它在特殊

楊澤業wordpress修改代碼沒有保存按鈕是怎麽回事呢?需要怎麽解決呢?

命令 size 技術 CI linux服務器 spa vertical 使用 ace 問題:wordpress修改代碼沒有保存按鈕是怎麽回事呢?需要怎麽解決呢?我們(通常是新手或者新上傳的模板)在WordPress後臺修改代碼的時候,發現代碼修改好了,卻沒有保存的按鈕,是怎

JS高級----------------->原型簡單的寫法(註意手動修改構造器的指向)

需要 htm -c 手動 idt 註意 log fun clas <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <titl

Java GUI將JPanel添加進JScrollPane

tco eache jtextarea 因此 add lse screen 滾動條 ner 實現的目標: 因為在滾動框中含有很多個Java GUI 組件,因此這裏采用JPanel面板包住這些組件,在用JScrollPane實現滾動 問題1:布局揉在一起 JPane

每天學習一個LINUX命令passwd 修改設置用戶密碼 (pass word 口令,通過語)

pass 更新 vpd 技術分享 oot 修改 時間 -o RoCE passwd命令用於設置用戶的認證信息,包括用戶密碼、密碼過期時間等。系統管理者則能用它管理系統用戶的密碼。只有root可以指定用戶名稱,一般用戶只能變更自己的密碼。 語法: passwd [參數] [

【原始碼】MATLAB GUI例項指導(41個例子,47個疑問解答)

MATLAB GUI的41個例項幫助大家學習如何在沒有GUIDE的情況下編寫圖形使用者介面程式。41個例項主要涉及以下47個問題: 如何在uicontrol中操作字串?(見GUI_1, 2, 4, 5, 13, 14, 15, 20, 21, 22, 37) 如何使u

關於matlab GUI的popupmenu

關於GUI的popupmenu,賦值 for i = 1 : 1 :length( subdir ) tempv=char(tempv,subdir( i ).name); end 一、將矩陣tempv輸入下拉選單: set(handles.popupmenu7, 'st

matlab GUI 實現資料夾選擇

matlab實現多個資料夾選擇 function [pathname] = uigetdir2(start_path, dialog_title) % Pick multiple directories and/or files import javax.swing.JFileCh

ubuntu 手動修改解析度為1920 X 1080 的兩種方式

方案一(臨時性,重啟會失效): 1、開啟終端。輸入:cvt 1920 1080 出現有modeline 的提示。 2、使用 xrandr 建立新的 mode,--newmode 後面跟剛剛 cvt 產生的 modeline 後面的資訊,如果去掉“_60.00”就可以在顯示器首選項中看到。 $ sudo