How do I display a matrix in a scrollable edit control?

I tried to display matrix values ​​in edit controls like this:

 LrOut = num2str(Lr(:, :, currentPosition));
    LqOut = num2str(Lq(:, :, currentPosition));
    set(handles.txtLr, 'String', LrOut);
    set(handles.txtLq, 'String', LqOut);

      

where txtLq and txtLr are editing controls:

alt text http://img534.imageshack.us/img534/2748/gui1e.jpg

When running the above code, the controls disappear: alt text http://img168.imageshack.us/img168/1910/gui2r.jpg

Lq and Lr are mxn matrices, where m and n are values ​​from 1 to 8 and up, so it would be helpful if the values ​​could be displayed in a scrollable edit control.

Does anyone know what might be causing the problem and how to change the current code to display the values ​​correctly and allow scrolling when the text exceeds the size of the control?

Thanks.

+2


a source to share


1 answer


You need to set the Max property for the edit control to the number of lines.

set(handles.txtLr, 'Max', size(Lr,1));
set(handles.txtLq, 'Max', size(Lq,1));

      

I also recommend that you take a look at UITABLE for matrix display. You can update the data with



set(handles.uitable1, 'Data', Lr(:, :, currentPosition))
set(handles.uitable2, 'Data', Lq(:, :, currentPosition))

      

Both will have a slider on the right and bottom if the data size exceeds the size of the control.

+4


a source







All Articles