MATLAB Answers

Oleg Komarov

TUTORIAL: how to format your question with markup

Asked by Oleg Komarov
on 6 Aug 2011
Latest activity Commented on by Image Analyst
on 10 May 2014

[INDEX]

--------------------------------------------------------------------------------------------------------------------------------------

[MOTIVATION]

Why should we use markups in the body of our questions?

The answer is a question: which of the two versions is more likely to be understood in a glimpse and has more chances to be answered by our readers?

.

< Consider the following question >

I have a vector of weights W=[10,20,30,50,23434,1,2.4,2] and a matrix A=rand(100,8) and I would like to find the row-wise weighted sum of A. I am proceeding in the following way: B=zeros(size(A)); for c=1:numel(W) B(:,c)=A(:,c)*W(c); end B=sum(B,2); Somehow I get huge numbers can you please help?

.

< Now, consider its formatted version >

I have a vector of weights W = [10,20,30,50,23434,1,2.4,2] and a matrix A = rand(100,8) and I would like to find the row-wise weighted sum of A.

I am proceeding in the following way:

B = zeros(size(A));
for c = 1:numel(W)
    B(:,c) = A(:,c)*W(c);
end
B = sum(B,2);

Somehow I get huge numbers can you please help?

--------------------------------------------------------------------------------------------------------------------------------------

[AKNOWLEDGMENTS]

In alphabetical order by nickname, thanks for their suggestions to:

Walter Roberson

--------------------------------------------------------------------------------------------------------------------------------------

[LOG]

  • 06 Aug 2011, 13:17 BST - created and added boldface.gif
  • 06 Aug 2011, 14:59 BST - added italic.gif
  • 06 Aug 2011, 18:58 BST - added index section
  • 07 Aug 2011, 00:03 BST - added code.gif and tutorial series section
  • 07 Aug 2011, 01:50 BST - added monospaced.gif, numlist.gif, bullist.gif and hyperlink.gif
  • 13 Aug 2011, 14:27 BST - added motivation section
  • 18 Aug 2011, 01:44 BST - added aknowledgments section and link to wish-list

--------------------------------------------------------------------------------------------------------------------------------------

[TUTORIAL Series]

Do not forget to read the Markup help (located on the top-right corner of the Body pane)

Vote on Wish-list for MATLAB Answer sections my post if you think that a tutorial section on top of Answers could be useful.

  14 Comments

Sean de Wolski
on 18 Oct 2012

Me too.

Ryan
on 18 Oct 2012

@Elige: Yes... the first two used tinypic the latter used uploadhouse. I uploaded the first two .gif's to uploadhouse for you.

Elige Grant
on 18 Oct 2012

Since my problems turned out to be unique to me, I deleted my above comments so as not to cause confusion.

Products

No products are associated with this question.

7 Answers

Answer by Oleg Komarov
on 6 Aug 2011

BOLDFACE

  1 Comment

Walter Roberson
on 10 Aug 2011

Note: the bold mode only works between pairs of * in the same paragraph. If you highlight several paragraphs (with empty lines between them) and click on the Bold button, although an * will be put on the first line and last line of the selection, the bold will "break" because of the empty lines.


Answer by Oleg Komarov
on 6 Aug 2011
Edited by Oleg Komarov
on 8 Aug 2013

ITALIC

  3 Comments

Walter Roberson
on 10 Aug 2011

Note: the italic mode only works between pairs of underscores in the same paragraph. If you highlight several paragraphs (with empty lines between them) and click on the Italic button, although an underscore will be put on the first line and last line of the selection, the italics will "break" because of the empty lines.

Jan Simon
on 23 Jul 2013

@Oleg: Please restore the picture.

Oleg Komarov
on 23 Jul 2013

Hopefully, I still have them. But will know this evening.


Answer by Oleg Komarov
on 7 Aug 2011

CODE

  2 Comments

Walter Roberson
on 10 Aug 2011

Note: the code formatting mode will last to the first empty line, even if there are no spaces at the beginning of the lines in the block.

Image Analyst
on 10 May 2014

Another tip: please, please, please indent your code in MATLAB correctly first, before pasting it in.

To do this highlight your code in the MATLAB editor (for example type Ctrl a to select all the text in the editor), then type Ctrl i. This "fixes/standardizes" your indentations. Then , paste your code in, and then click {}Code. DO NOT TYPE {}Code before you paste in your code.


Answer by Oleg Komarov
on 7 Aug 2011

MONOSPACED

  1 Comment

Walter Roberson
on 12 Aug 2011

Note: the monospaced mode only works between pairs of bars in the same paragraph. If you highlight several paragraphs (with empty lines between them) and click on the monospace button, although an bar will be put on the first line and last line of the selection, the monospace will "break" because of the empty lines.


Answer by Oleg Komarov
on 7 Aug 2011

NUMBERED LIST

  3 Comments

Walter Roberson
on 7 Aug 2011

Note: here must be a blank line before and after the # list

Walter Roberson
on 8 Aug 2011

Note: there must be a space after the #

Walter Roberson
on 12 Aug 2011

Note: the numbering sequence restarts at each empty line, so do _not_ put blank lines between the portions.

Note: the # must be after a "real" line break, where carriage return was typed at the end of the previous line; it is not sufficient to put it at what looks like the beginning of a line, if the line has been automatically wrapped down from the previous line.


Answer by Oleg Komarov
on 7 Aug 2011

BULLETED LIST

  3 Comments

Walter Roberson
on 7 Aug 2011

Note: there must be a blank line before and after the * list.

Walter Roberson
on 8 Aug 2011

Note: there must be a space after the *

Walter Roberson
on 12 Aug 2011

Note: the * must be after a "real" line break, where carriage return was typed at the end of the previous line; it is not sufficient to put it at what looks like the beginning of a line, if the line has been automatically wrapped down from the previous line.


Answer by Oleg Komarov
on 7 Aug 2011

HYPERLINK

  3 Comments

Walter Roberson
on 7 Aug 2011

Simple hyperlinks are _not_ converted automatically by the site: that is being done by browsers.

Walter Roberson
on 12 Aug 2011

Note: ensure that there is no whitespace space immediately after the < or immediately before the > or else the link will not be created.

Walter Roberson
on 8 Sep 2011

Note: there must be whitespace (or beginning of line) immediately before the < or else the link will not be created. In particular, some people like to put links in brackets such as (<some link or other>) and that will not work because there must be a space before the < .


Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply today