MATLAB Answers

0

How to display multiple lines as output from code in edit text field in app designer

Asked by Deepak Prakash K on 17 Dec 2018
Latest activity Edited by Deepak Prakash K on 17 Dec 2018
Hi. I'm trying to display multiple lines as output from my code in the edit text field in app designer. I tried implementing the following way (test code).
app.double_results.Value = sprintf('Max velocity can be reached but 1st gear ratio can be increased\n');
app.double_results.Value = sprintf('%s \r\n %s',app.double_results.Value,'Hi');
But the two strings were not displayed in two lines as shown below.
How should I modify the commands to display the two strings as seperate lines?
Btw, I'm using Matlab 2018a.

  0 Comments

Sign in to comment.

1 Answer

Answer by Kevin Chng on 17 Dec 2018
Edited by Kevin Chng on 17 Dec 2018

Hi, try this way
app.TextArea.Value = sprintf('Max velocity can be reached but 1st gear ratio can be increased\n');
app.TextArea.Value = [app.TextArea.Value;"hi"]
Accept my answer if it is working for you. Thanks

  5 Comments

I am getting the same error as before - 'Value' must be a character vector or a string scalar.
Was there any additional edits you made to the text field?
12.png
Nothing I have made to the text field. Above is my code for the button callback. Since I have to install R2018a, I can try to emulate the same thing in R2018a at night (My time zone is GMT + 8), then investigate why don't it working in 2018a.
Ok thanks. Please let me know if you're able to implement it with 2018a. I shall also try to figure out a way and will let you know if something works.

Sign in to comment.