我是初学者。我想问,如何将编辑文本放入矩阵?例如,我有 30 个编辑文本,将由数字 0 - 1 填充。我想从编辑文本的输入中制作矩阵x(1,1)
,....。x(1,30)
我试过这段代码:
function edit1_Callback(hObject, eventdata, handles)
% hObject handle to edit1 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit1 as text
% str2double(get(hObject,'String')) returns contents of edit1 as a double
x(1, 1) = str2double(get(hObject,'string'))
直到....
function edit30_Callback(hObject, eventdata, handles)
% hObject handle to edit30 (see GCBO)
% eventdata reserved - to be defined in a future version of MATLAB
% handles structure with handles and user data (see GUIDATA)
% Hints: get(hObject,'String') returns contents of edit30 as text
% str2double(get(hObject,'String')) returns contents of edit30 as a double
x(1, 30) = str2double(get(hObject,'string'))
但是,命令窗口显示是这样的......
x =
1
x =
0 0
x =
0 0 0
x =
0 0 0 0.2500
x =
0 0 0 0 0.5000
x =
0 0 0 0 0 0
但实际上我想要的结果是矩阵,比如
1 0 0 0.25 0.5 0
有谁知道如何解决这个问题?