Matlab GUI: changing multiple lines static text

B='b';C='c';D='d';E='e';F='f';G='g';H='h';I='i';J='j';K='k';L='l'; set(handles.text1,'String',{A;B;C;D;E;F;G;H;I;J;K;L});In summary, The conversation discusses a problem while creating a Matlab GUI and the issue of trying to display multiple lines in one static text. The speaker shares their code and the error they encountered when trying to change one of the elements. A solution is proposed to use cells instead of a character array.
  • #1
robuLAB
5
0
hi,
I'm ran into a problem while creating a Matlab GUI and I can't seem to find out why.
I'm trying to get multiple lines in one static text. I set the 'max' property on 12 and then wrote the following code to test:

Code:
A='a';B='b';C='c';D='d';E='e';F='f';G='g';H='h';I='i';J='j';K='k';L='l';
        
set(handles.text1,'String',[A;B;C;D;E;F;G;H;I;J;K;L]);
that seems to work fine, but when I change A to for example 'this is a test', I get an error saying there's something wrong with my set instruction.
I can't seem to be able to display more than one letter for each string.
Can anyone help me with this?
 
Physics news on Phys.org
  • #2
Try setting all of your elements as cells (with the braces) so that you end up with a cell array of strings rather than a character array - your error may have something to do with that because with a character array, if A,B,C, etc. cannot have a different number of elements.

e.g.:

Code:
A={'blah blah whatever'};
 

1. How can I change the text of multiple lines in a Matlab GUI?

To change the text of multiple lines in a Matlab GUI, you can use the set(handles.element_name, 'String', 'new_text') command. This will allow you to specify the specific element you want to change the text of, and the new text you want to display.

2. Can I change the font size and style of multiple lines in a Matlab GUI?

Yes, you can change the font size and style of multiple lines in a Matlab GUI. To do so, you can use the set(handles.element_name, 'FontSize', font_size) and set(handles.element_name, 'FontName', 'font_name') commands, respectively. You can also use the set(handles.element_name, 'FontWeight', 'bold') command to make the text bold.

3. Is it possible to change the color of multiple lines in a Matlab GUI?

Yes, you can change the color of multiple lines in a Matlab GUI. You can use the set(handles.element_name, 'ForegroundColor', color) command to specify the color you want to use for the text. Additionally, you can use the set(handles.element_name, 'BackgroundColor', color) command to change the background color of the element.

4. How can I change the alignment of multiple lines in a Matlab GUI?

To change the alignment of multiple lines in a Matlab GUI, you can use the set(handles.element_name, 'HorizontalAlignment', 'alignment') command. The alignment can be set to 'left', 'center', or 'right' to specify the desired alignment.

5. Can I change the text of multiple lines in a Matlab GUI dynamically?

Yes, you can change the text of multiple lines in a Matlab GUI dynamically. This means that the text can be changed during the execution of the program. To do this, you can use the handles.dynamic_text = 'new_text' command to change the text of the element, and then use guidata(hObject, handles) to update the GUI with the new text.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
212
  • MATLAB, Maple, Mathematica, LaTeX
Replies
7
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
921
  • MATLAB, Maple, Mathematica, LaTeX
Replies
14
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Precalculus Mathematics Homework Help
Replies
21
Views
586
  • Calculus and Beyond Homework Help
Replies
2
Views
122
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
Back
Top