MATLAB Answers

GUI help to add space in lines

Asked by Lalit Patil on 16 Dec 2012
HelpTitle='Help';
A1 = '         MSU';
A2 = '         DEE';
A5 = 'start';
A6 = 'stop';
A7 = 'Save';
A8 = 'Images';
A9 = 'Create';
dialogue=strvcat(1,A1,A2,A3,A4,A5,A6,A7,A8,A9);
helpdlg(dialogue,HelpTitle);

I am creating Help menu In GUI, I have put a push button and written above script behind it...

In this script between A2 and A5 there will be A3 and A4, and I want to add space in this two lines, so how to add?

  3 Comments

Image Analyst
on 16 Dec 2012

When you paste your code, you don't need to have blank lines between the code lines to get them to show up on separate lines. Just paste in your code, highlight it all, and click the {}Code button above. It will look fine if you do that. I've fixed it for you.

Lalit Patil on 16 Dec 2012

Every time i adviced to format my code when i am paste it.. and i am also trying it..

But when i am pressing {} button, it shows

if true
  % code
end

I didn't want any if condition in my code, so how i can post here using {}..

Image Analyst
on 16 Dec 2012

Yeah, confusing I admit. I think you're supposed not press that button first. First paste in your code and highlight it. THEN click that button. Try it that way instead.

Products

No products are associated with this question.

2 Answers

Answer by Walter Roberson
on 16 Dec 2012
 Accepted answer
dialogue = {A1, A2, '', '', A5, A6, A7, A8, A9};

  0 Comments


Answer by Image Analyst
on 16 Dec 2012

An alternate way using sprintf() and \n to insert blank lines:

HelpTitle='Help';
A1 = '         MSU';
A2 = '         DEE';
A5 = 'start';
A6 = 'stop';
A7 = 'Save';
A8 = 'Images';
A9 = 'Create';
dialogue= sprintf('%s\n%s\n\n%s\n%s\n%s\n%s\n%s',...
	A1,A2,A5,A6,A7,A8,A9); % The backslash n inserts a blank line.
helpdlg(dialogue,HelpTitle);

  0 Comments


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today