私は初心者です。質問したいのですが、編集テキストをマトリックスに入れる方法は? x(1,1)
たとえば、0 から 1 の数字で塗りつぶされる 30 個の編集テキストがあります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
この問題を解決する方法を知っている人はいますか?