Thread Subject: comma before line warning

Subject: comma before line warning

From: Juliette Salexa

Date: 13 Jul, 2009 19:48:03

Message: 1 of 6

triples={'CCG(i)', 'CGC(i)', 'CGG(i)', 'GCC(i)', 'GCG(i)', 'GGC(i)'};

quadruples={'CCCC(i)',
'CCCG(i)',
'CCGC(i)',
'CCGG(i)'};
----------------
In the case of the quadruples, my m-file editor gives me the warning "comma before line may incorrectly suggest row continuation"

When I run the m-file, I indeed get dissimilar structures in my command window:
----------------
triples =
    'CCG(i)' 'CGC(i)' 'CGG(i)' 'GCC(i)' 'GCG(i)' 'GGC(i)'

quadruples =
    'CCCC(i)'
    'CCCG(i)'
    'CCGC(i)'
    'CCGG(i)'
----------------
but they appear to be the same:
>>quadruples{2}
ans =CCCG(i)
>>triples{2}
ans =CGC(i)
----------------
Is there a difference ?? should I be concerned ??

triples was typed out manually, while quadruples came from a 4x10 character matrix.. each row being a character array like " 'CCCC(i)', "

Subject: comma before line warning

From: Rune Allnor

Date: 13 Jul, 2009 20:00:39

Message: 2 of 6

On 13 Jul, 21:48, "Juliette Salexa" <juliette.physic...@gmail.com>
wrote:
> triples={'CCG(i)', 'CGC(i)', 'CGG(i)', 'GCC(i)', 'GCG(i)', 'GGC(i)'};
>
> quadruples={'CCCC(i)',
> 'CCCG(i)',
> 'CCGC(i)',
> 'CCGG(i)'};
> ----------------
> In the case of the quadruples, my m-file editor gives me the warning "comma before line may incorrectly suggest row continuation"

I get no such warnings (R2006a). Try to remove the
commas in your .m file:

quadruples={'CCCC(i)'
'CCCG(i)'
'CCGC(i)'
'CCGG(i)'};

Rune

Subject: comma before line warning

From: Juliette Salexa

Date: 13 Jul, 2009 20:25:21

Message: 3 of 6

Thanks Rune, I'm using R2007b and I get the warnings.

If I remove the commas is the data structure going to turn out the same ??
--
Also, let's say I did something like:

c(1:3,1:3)=repmat('ab,',3,1)
c =
ab,
ab,
ab,

and wanted to copy and paste

ab,
ab,
ab,

into my m-file editor WITHOUT the '\n' at the end of every line. Does matlab have a method to remove those '\n' s ??

I don't like copying and pasting into vim, removing the \n's and then pasting back into the m-file editor.

Subject: comma before line warning

From: Steven Lord

Date: 13 Jul, 2009 21:40:04

Message: 4 of 6


"Juliette Salexa" <juliette.physicist@gmail.com> wrote in message
news:h3g31j$fd8$1@fred.mathworks.com...
> triples={'CCG(i)', 'CGC(i)', 'CGG(i)', 'GCC(i)', 'GCG(i)', 'GGC(i)'};
>
> quadruples={'CCCC(i)',
> 'CCCG(i)',
> 'CCGC(i)',
> 'CCGG(i)'};
> ----------------
> In the case of the quadruples, my m-file editor gives me the warning
> "comma before line may incorrectly suggest row continuation"

You mean that the second block of code gives an M-Lint warning?

> When I run the m-file, I indeed get dissimilar structures in my command
> window:
> ----------------
> triples =
> 'CCG(i)' 'CGC(i)' 'CGG(i)' 'GCC(i)' 'GCG(i)' 'GGC(i)'
>
> quadruples =
> 'CCCC(i)'
> 'CCCG(i)'
> 'CCGC(i)'
> 'CCGG(i)'

Yes. Because you had newlines in your defintion of quadruples, it was
created as a column cell array, not a row cell array. Compare these three
vectors:

x = [1,
2,
3]

y = [1, ...
2, ...
3]

z = [1
2
3]

x and z are 3-by-1 vectors, while y is 1-by-3. The newlines take precedence
over the commas, and that's what the M-Lint message is warning you about in
case you'd intended to create y but instead created x.

> ----------------
> but they appear to be the same:
>>>quadruples{2}
> ans =CCCG(i)
>>>triples{2}
> ans =CGC(i)

They are oriented differently.

> Is there a difference ?? should I be concerned ??

Yes to your first question, it depends on what you're using the variables
for to your second question. If your code expects a row cell array instead
of a column cell array, then you should be concerned.

--
Steve Lord
slord@mathworks.com

Subject: comma before line warning

From: Juliette Salexa

Date: 13 Jul, 2009 22:00:21

Message: 5 of 6

Thank you Steven, that was very helpful.

Now if anyone knows how to get rid of the "\n" at the end of each line (see my reply to Rune in this same thread), I'd be excited to see!

Subject: comma before line warning

From: Rune Allnor

Date: 14 Jul, 2009 03:55:02

Message: 6 of 6

On 13 Jul, 22:25, "Juliette Salexa" <juliette.physic...@gmail.com>
wrote:
> Thanks Rune, I'm using R2007b and I get the warnings.  
>
> If I remove the commas is the data structure going to turn out the same ??
> --
> Also, let's say I did something like:
>
> c(1:3,1:3)=repmat('ab,',3,1)
> c =
> ab,
> ab,
> ab,
>
> and wanted to copy and paste
>
> ab,
> ab,
> ab,
>
> into my m-file editor WITHOUT the '\n' at the end of every line.  Does matlab have a method to remove those '\n' s ??
>
> I don't like copying and pasting into vim, removing the \n's and then pasting back into the m-file editor.

A = {1,2,3};
B = reshape(A,length(A),1);
whos

  Name Size Bytes Class

  A 1x3 204 cell array
  B 3x1 204 cell array

Rune

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Contact us at files@mathworks.com