http://www.mathworks.com/matlabcentral/newsreader/view_thread/315071
MATLAB Central Newsreader  Error using ==> mldivide
Feed for thread: Error using ==> mldivide
enus
©19942015 by MathWorks, Inc.
webmaster@mathworks.com
MATLAB Central Newsreader
http://blogs.law.harvard.edu/tech/rss
60
MathWorks
http://www.mathworks.com/images/membrane_icon.gif

Thu, 08 Dec 2011 02:11:08 +0000
Error using ==> mldivide
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315071#860830
William
I wanted to run a fairly simple program and thought it would be easy, however I'm having trouble. I thought I troubleshooted (is that the correct past tense, troubleshot?) the code but can't seem to get it. <br>
<br>
I'm sure you pros will have it figured it out in seconds...<br>
<br>
function ch2_23 (t)<br>
%created by so and so<br>
<br>
e_minus_ef=[0.2:0.01:0.2];<br>
k = 8.62*10^(5);<br>
<br>
<br>
y = 1/(1+exp(e_minus_ef ./ (k.*t) ));<br>
<br>
plot(y,e_minus_ef);<br>
_____________________________<br>
<br>
The error I get when I run the script is....<br>
<br>
??? Error using ==> mldivide<br>
Matrix dimensions must agree.<br>
<br>
Error in ==> ch2_23 at 8<br>
y = 1/(1+exp(e_minus_ef ./ (k.*t) ));<br>
<br>
________________________________<br>
<br>
All help will be greatly appreciated!<br>
<br>
Thank you.

Thu, 08 Dec 2011 06:16:09 +0000
Re: Error using ==> mldivide
http://www.mathworks.com/matlabcentral/newsreader/view_thread/315071#860844
Roger Stafford
"William" wrote in message <jbp6bs$23j$1@newscl01ah.mathworks.com>...<br>
> e_minus_ef=[0.2:0.01:0.2];<br>
> y = 1/(1+exp(e_minus_ef ./ (k.*t) ));<br>
> ??? Error using ==> mldivide<br>
> Matrix dimensions must agree.<br>
        <br>
The mistake is in the use of '/' in the first part of the line<br>
<br>
y = 1/(1+exp(e_minus_ef ./ (k.*t) ));<br>
<br>
Since the denominator is not a scalar, this division is interpreted as matlab's "matrix division" in which the result will have as many rows as the numerator and as many columns as there are rows in the denominator, and in which the numerator and denominator must have equal numbers of columns. The latter violation is the source of your error message. This holds true even with a scalar numerator. You are lucky your denominator wasn't a column vector for which there would have been no error message but a very mystifying row vector result. You should read all about matrix division in the pertinent Mathworks' documentation.<br>
<br>
I think you meant to have 1 divided by each element of the denominator which is quite a different operation. For this you should use './' :<br>
<br>
y = 1./(1+exp(e_minus_ef ./ (k.*t) ));<br>
<br>
Roger Stafford