Thread Subject:
empty matrix to be equivalent to scalar null

Subject: empty matrix to be equivalent to scalar null

From: rych

Date: 8 May, 2011 09:27:23

Message: 1 of 2

I have a term with A(1:k-1)*...

For k = 1 I want that term to vanish automatically by having A(1:k-1)
treated as zero

Instead it gives me an error, e.g. "Inner matrix dimensions must
agree"

Currently I have to write a condition inside the loop body if k>1 ...
else ...

Is there a more elegant solution?

Thanks
Igor

Subject: empty matrix to be equivalent to scalar null

From: Steven_Lord

Date: 9 May, 2011 01:20:02

Message: 2 of 2



"rych" <rychphd@gmail.com> wrote in message
news:552f7670-f5fd-48ec-9135-cfe10503986f@x38g2000pri.googlegroups.com...
> I have a term with A(1:k-1)*...
>
> For k = 1 I want that term to vanish automatically by having A(1:k-1)
> treated as zero
>
> Instead it gives me an error, e.g. "Inner matrix dimensions must
> agree"
>
> Currently I have to write a condition inside the loop body if k>1 ...
> else ...
>
> Is there a more elegant solution?

No. A(1:k-1) is the same size as (1:k-1) which for k = 1 is 1:0. Thus A(1:0)
is 1-by-0.

--
Steve Lord
slord@mathworks.com
To contact Technical Support use the Contact Us link on
http://www.mathworks.com

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