我需要在MATLAB中爲我的項目創建一個GUI。我到處尋找如何編程GUI的例子,但我找不到很多。 MATLAB中的GUI編程有哪些好的站點或技術?如何在MATLAB中編程GUI?
8
A
回答
11
您需要去的第一個地方是Matlab幫助Creating Graphical User Interfaces 。
然後,您可以觀看this tutorial video或this one
This tutorial也不錯。
8
這裏是我作出了關於使MATLAB的GUI
2
我最近有編程控制一些情節簡單的GUI的所有視頻。我不確切知道你的任務是什麼,但這裏有一些基本的代碼讓你開始。這創造了兩個數字;圖1有對照,圖2有一個y = x^p的圖。您在框中輸入p的值,然後按Enter鍵註冊並重新繪製;然後按按鈕重置爲默認值p = 1。
function SampleGUI()
x=linspace(-2,2,100);
power=1;
y=x.^power;
ctrl_fh = figure; % controls figure handle
plot_fh = figure; % plot figure handle
plot(x,y);
% uicontrol handles:
hPwr = uicontrol('Style','edit','Parent',...
ctrl_fh,...
'Position',[45 100 100 20],...
'String',num2str(power),...
'CallBack',@pwrHandler);
hButton = uicontrol('Style','pushbutton','Parent',ctrl_fh,...
'Position',[45 150 100 20],...
'String','Reset','Callback',@reset);
function reset(source,event,handles,varargin) % boilerplate argument string
fprintf('resetting...\n');
power=1;
set(hPwr,'String',num2str(power));
y=x.^power;
compute_and_draw_plot();
end
function pwrHandler(source,event,handles,varargin)
power=str2num(get(hPwr,'string'));
fprintf('Setting power to %s\n',get(hPwr,'string'));
compute_and_draw_plot();
end
function compute_and_draw_plot()
y=x.^power;
figure(plot_fh); plot(x,y);
end
end
GUI背後的基本思想是,當你操縱控件時,他們稱之爲「回調」函數,即事件處理程序;這些函數能夠通過使用控制手柄和set/get方法獲取或更改其屬性的控件進行交互。要獲取可用屬性列表,請仔細閱讀Matlab文檔網站(http://www.mathworks.com/access/helpdesk/help/techdoc/infotool/hgprop/doc_frame.html)上非常豐富的Handle圖形屬性瀏覽器;點擊UI對象(或其他任何你需要的)。
希望這會有所幫助!
2
這些41 complete GUI examples發佈到MathWorks File Exchange通過Matt Fig是一個很好的開始。提交的內容甚至是Pick of the Week。
相關問題
- 1. 在Matlab GUI和函數中編程
- 2. 如何在GUI,Matlab中編程對話框?
- 3. 如何以編程方式更改選項卡在MATLAB GUI
- 4. 在Matlab GUI中編輯複選框
- 5. MATLAB:從編程GUI返回變量
- 6. 如何在matlab中閃爍圖像gui
- 7. 如何在MATLAB GUI中顯示點雲?
- 8. 在MATLAB中的進程中停止GUI
- 9. 在python編程中的GUI
- 10. 在Matlab的GUI中繪圖
- 11. 如何在後臺更新MATLAB GUI?
- 12. 在matlab中編程字符
- 13. GUI編程Pyqt
- 14. C++編程GUI
- 15. Javafx GUI編程
- 16. Netbeans GUI編程
- 17. WxPython GUI編程。
- 18. python gui編程
- 19. 集編譯MATLAB GUI文件夾
- 20. 如何確定編輯框是否溢出(Matlab GUI)?
- 21. 如何安排任務與GUI編程
- 22. LISP中的GUI編程?
- 23. tkinter gui編程中的AttributeError
- 24. 如何在Matlab GUI中在軸上繪製垂直線?
- 25. 將MATLAB GUI添加到MATLAB代碼中
- 26. Matlab GUI表
- 27. 關於Matlab GUI
- 28. 在MATLAB GUI中單擊鼠標單擊編輯框清除
- 29. 在編譯的GUI中的圖像位置 - MATLAB
- 30. 在Matlab GUI中創建一個不可編輯的行