The Math Forum

Search All of the Math Forum:

Views expressed in these public forums are not endorsed by NCTM or The Math Forum.

Math Forum » Discussions » Software » comp.soft-sys.matlab

Notice: We are no longer accepting new posts, but the forums will continue to be readable.

Topic: Matrix dimensions must agree.
Replies: 13   Last Post: Mar 24, 2014 5:34 PM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]

Posts: 9,850
Registered: 6/7/07
Re: Matrix dimensions must agree.
Posted: Mar 20, 2014 1:30 PM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

On 3/20/2014 12:22 PM, Vitor Andrade wrote:
> I'm new programmer, so I need to help of you.
> I have two matrices, wherein I would like to subtract one from the other:
> Comprimento = pe2(:,2) - pe1(:,2);
> But, my arrays are sizes different, one the size 11x2 and other the size
> 12x2. However, I would like to delete the row where my error occurs and
> continue my calculations.
> I hope I have to been clearer.

A) Enclose the error-throwing code in a try...catch block

B) Use "defensive programming" and test for the size mismatch and either
don't execute the known-to-fail code or fixup the size mismatch so it
doesn't fail.


Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© The Math Forum at NCTM 1994-2018. All Rights Reserved.