Matlab GUI: changing multiple lines static text

Click For Summary
SUMMARY

The discussion focuses on creating a MATLAB GUI that displays multiple lines of static text using the 'set' function. The user initially attempts to set the 'String' property with a character array but encounters an error when trying to input a string longer than one character. The solution provided suggests using a cell array of strings instead of a character array, specifically by defining strings with braces, e.g., A={'blah blah whatever'}. This approach resolves the issue and allows for proper multi-line text display.

PREREQUISITES
  • Familiarity with MATLAB GUI development
  • Understanding of MATLAB 'set' function for UI components
  • Knowledge of character arrays versus cell arrays in MATLAB
  • Basic programming skills in MATLAB
NEXT STEPS
  • Explore MATLAB GUI components and their properties
  • Learn about cell arrays in MATLAB and their advantages
  • Investigate error handling in MATLAB GUI applications
  • Study examples of multi-line text display in MATLAB GUIs
USEFUL FOR

MATLAB developers, GUI designers, and anyone looking to enhance their skills in creating user interfaces with multi-line text capabilities in MATLAB.

robuLAB
Messages
5
Reaction score
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
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'};
 

Similar threads

  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 4 ·
Replies
4
Views
18K
  • · Replies 14 ·
Replies
14
Views
4K
  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
4K
  • · Replies 1 ·
Replies
1
Views
3K