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

歡迎訪問 生活随笔!

生活随笔

當前位置: 首頁 > 人工智能 > 循环神经网络 >内容正文

循环神经网络

matlab功能块,Matlab GUI重用功能块

發布時間:2023/12/20 循环神经网络 28 豆豆
生活随笔 收集整理的這篇文章主要介紹了 matlab功能块,Matlab GUI重用功能块 小編覺得挺不錯的,現在分享給大家,幫大家做個參考.

我在GUIDE中創建了一個帶有兩個可編輯文本框和四個靜態文本框的Matlab GUI

用戶在兩個可編輯的文本框(e1和e2)中輸入值,并根據這些值計算應在靜態文本框(s1,s2,s3和s4)中顯示的值.

它在e1和e2的每個值變化上執行此操作

e1更改值時計算值的代碼如下所示.

% --- Executes on key press with focus on e1 and none of its controls.

function e1_KeyPressFcn(hObject, eventdata, handles)

% hObject handle to e1 (see GCBO)

% eventdata structure with the following fields (see UICONTROL)

% Key: name of the key that was pressed, in lower case

% Character: character interpretation of the key(s) that was pressed

% Modifier: name(s) of the modifier key(s) (i.e., control, shift) pressed

% handles structure with handles and user data (see GUIDATA)

% Start of BLOCK

% Get values from e1 and e2 and calculate other values

handles.levels = str2num(get(handles.e1, 'String'));

handles.edgelength = str2num(get(handles.e2, 'String'));

handles.cellnum = (handles.levels^3 + 3*handles.levels^2 + 2*handles.levels)/6;

handles.vertnum = ((handles.levels+1)^3 + 3*(handles.levels+1)^2 + 2*(handles.levels+1))/6;

% Set values of s1, s2, s3 and s4

set(handles.s1, 'String', num2str(handles.cellnum));

set(handles.s2, 'String', num2str(handles.vertnum));

set(handles.s3, 'String', num2str(0.433*handles.edgelength^2));

set(handles.s4, 'String', ...

num2str(2*handles.cellnum*str2num(get(handles.s3, 'String'))));

% End of BLOCK

是否可以引用這段代碼(包含在BLOCK中),以便函數e2_KeyPressFcn也可以使用它?

現在我只是將該部分復制粘貼到函數e2_KeyPressFcn,但這似乎不是很優雅.

最佳答案 如何為您的代碼塊創建幫助函數?

我正在考慮以下幾點:

function e1_KeyPressFcn(hObject, eventdata, handles)

handles = helper_block_func(handles);

function e2_KeyPressFcn(hObject, eventdata, handles)

handles = helper_block_func(handles);

function hout = helper_block_func(hin)

hout = hin;

% # Get values from e1 and e2 and calculate other values

hout.levels = str2num(get(hout.e1, 'String'));

hout.edgelength = str2num(get(hout.e2, 'String'));

hout.cellnum = (hout.levels ^ 3 + 3 * hout.levels ^ 2 + 2 * hout.levels) / 6;

hout.vertnum = ((hout.levels + 1) ^ 3 + 3 * (hout.levels + 1) ^ 2 ...

+ 2 * (hout.levels + 1)) / 6

% # Set values of s1, s2, s3 and s4

set(hout.s1, 'String', num2str(hout.cellnum));

set(hout.s2, 'String', num2str(hout.vertnum));

set(hout.s3, 'String', num2str(0.433 * hout.edgelength ^ 2));

set(hout.s4, 'String', ...

num2str(2 * hout.cellnum * str2num(get(hout.s3, 'String'))));

總結

以上是生活随笔為你收集整理的matlab功能块,Matlab GUI重用功能块的全部內容,希望文章能夠幫你解決所遇到的問題。

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