当前位置: 首页 > 工具软件 > M edit > 使用案例 >

matlab 获取edit,关于matlab的gui中获取edit值的问题

施子民
2023-12-01

本帖最后由 李昊波 于 2017-7-16 11:12 编辑

想请教一个问题,制作了一个有24个edit的gui程式,想获取edit中的数值然后用这些数值来做排列组合,但是运行结果显示为生成了一个空的矩阵

>> one

result =

空的 0×8 double 矩阵

下面是edit的callback部分的程式(因为都类似所以只贴了一个)

a = get(handles.edit1, 'value');

handles.L1 = a;

guidata(hObject, handles);

下面是最后的计算的pushbutton的callback程式:

function start_Callback(hObject, eventdata, handles)

% hObject    handle to start (see GCBO)

% eventdata  reserved - to be defined in a future version of MATLAB

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

L1 = handles.L1;

L2 = handles.L2;

L3 = handles.L3;

h11 = handles.h11;

h12 = handles.h12;

h13 = handles.h13;

h21 = handles.h21;

h22 = handles.h22;

h23 = handles.h23;

h31 = handles.h31;

h32 = handles.h32;

h33 = handles.h33;

T1 = handles.T1;

T2 = handles.T2;

T3 = handles.T3;

R1 = handles.R1;

R2 = handles.R2;

R3 = handles.R3;

C1 = handles.C1;

C2 = handles.C2;

C3 = handles.C3;

K1 = handles.K1;

K2 = handles.K2;

K3 = handles.K3;

L = linspace(L1,L2,L3);

h1 = linspace(h11,h12,h13);

h2 = linspace(h21,h22,h23);

h3 = linspace(h31,h32,h33);

T = linspace(T1,T2,T3);

R = linspace(R1,R2,R3);

C = linspace(C1,C2,C3);

K = linspace(K1,K2,K3);

A = {L,h1,h2,h3,T,R,C,K};

m = length(A);

[c{1:m}] = deal(A{:});

[x{1:m}] = ndgrid(c{:});

result = reshape(cat(m+1,x{:}),[],m)

运行的结果显示为一个空矩阵,但是如果我把后面一部分程式拿来直接运行,把L1 = handles.L1这些命令直接替换成L1 = 1之类的命令,是可以运行出合理的结果的,所以应该就是edit部分的赋值程式出现了问题,但是本人实在是水平有限不太明白,希望有大侠可以指点一下,万分感谢!

 类似资料: