Discover MakerZone

MATLAB and Simulink resources for Arduino, LEGO, and Raspberry Pi

Learn more

Discover what MATLAB® can do for your career.

Opportunities for recent engineering grads.

Apply Today

Thread Subject:
What is mlint doing here?

Subject: What is mlint doing here?

From: Chuck37

Date: 10 Jun, 2013 16:24:19

Message: 1 of 2

I have some code like this:

Mi = inv( a 2x2 matrix );
for x = 1:hugeNum
  ...
  a = b'*Mi*b;
  ...
end

Mlint complains at the line inside the loop where Mi is used, suggesting that I use a/B instead of a*Bi etc. What is it thinking? Surely taking the inverse once is better than doing it a million times inside the loop, even if it's not explicitly doing an inverse. Using inv at the top is just a convenience anyway, I expect I could write out the inverse explicitly and the complaint would go away.

I'm plagued by this mlint complaint generally. Sometimes I comply to make the error go away (I start the other way in the name of readability), but haven't really experimented to see if there is a speed difference for smallish matrices.

Subject: What is mlint doing here?

From: Josh Meyer

Date: 10 Jun, 2013 17:03:25

Message: 2 of 2

Check out the "Linear Equations" chapter of Cleve Moler's book:

http://www.mathworks.com/moler/lu.pdf

This chapter answers your question in detail.

"Chuck37 " <chuck3737@yahooremovethis.com> wrote in message
news:kp4ujj$ooh$1@newscl01ah.mathworks.com...
> I have some code like this:
>
> Mi = inv( a 2x2 matrix );
> for x = 1:hugeNum
> ...
> a = b'*Mi*b;
> ...
> end
>
> Mlint complains at the line inside the loop where Mi is used, suggesting
> that I use a/B instead of a*Bi etc. What is it thinking? Surely taking
> the inverse once is better than doing it a million times inside the loop,
> even if it's not explicitly doing an inverse. Using inv at the top is
> just a convenience anyway, I expect I could write out the inverse
> explicitly and the complaint would go away.
>
> I'm plagued by this mlint complaint generally. Sometimes I comply to make
> the error go away (I start the other way in the name of readability), but
> haven't really experimented to see if there is a speed difference for
> smallish matrices.

Tags for this Thread

No tags are associated with this thread.

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.

Contact us