Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

MATLAB GUI Edit text to Matrix

  1. Mar 5, 2012 #1
    0 down vote favorite
    share [g+] share [fb] share [tw]


    Hi...I'm the beginner. I want to ask, how to put edit text to matrix? For example,
    I have 30 edit text that will fill by number 0 - 1.
    I want to make matrix x(1,1),....x(1,30) from the input of edit text.

    I have tried this code :

    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'))


    till....

    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'))

    but, the command window show like this...

    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

    but actually I want the result is matrix, like

    1 0 0 0.25 0.5 0

    Does anyone know how to solve this problem?
     
  2. jcsd
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook

Can you offer guidance or do you also need help?
Draft saved Draft deleted



Similar Discussions: MATLAB GUI Edit text to Matrix
  1. Matlab GUI question (Replies: 2)

Loading...