<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.es/matlabcentral/newsreader/view_thread/318266</link>
    <title>MATLAB Central Newsreader - Error Message "Subscripted assignment dimension mismatch"</title>
    <description>Feed for thread: Error Message "Subscripted assignment dimension mismatch"</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2013 by MathWorks, Inc.</copyright>
    <webmaster>webmaster@mathworks.com</webmaster>
    <generator>MATLAB Central Newsreader</generator>
    <docs>http://blogs.law.harvard.edu/tech/rss</docs>
    <ttl>60</ttl>
    <image>
      <title>MathWorks</title>
      <url>http://www.mathworks.es/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Fri, 23 Mar 2012 06:26:22 +0000</pubDate>
      <title>Error Message "Subscripted assignment dimension mismatch"</title>
      <link>http://www.mathworks.es/matlabcentral/newsreader/view_thread/318266#870917</link>
      <author>Guan Hong </author>
      <description>Hi, I have encountered an error message "Subscripted assignment dimension mismatch" while running the m-file below. I would like to seek your expertise as I am new to MatLab. Your help will be greatly appreciated.&lt;br&gt;
&lt;br&gt;
%---------Pairwise Comparison: Eigenvector Method-------------&lt;br&gt;
disp('----Pairwise Comparison: Eigenvector Method----')&lt;br&gt;
PM =[1/1 4/1 8/7 8/3 8/7 1/1 8/5 8/1 4/3 4/3;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1/4 1/1 2/7 2/3 2/7 1/4 2/5 2/1 1/3 1/3;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7/8 7/2 1/1 7/3 1/1 7/8 7/5 7/1 7/6 7/6;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3/8 3/2 3/7 1/1 3/7 3/8 3/5 3/1 1/2 1/2;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;7/8 7/2 1/1 7/3 1/1 7/8 7/5 7/1 7/6 7/6;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1/1 4/1 8/7 8/3 8/7 1/1 8/5 8/1 4/3 4/3;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;5/8 5/2 5/7 5/3 5/7 5/8 1/1 5/1 5/6 5/6;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;1/8 1/2 1/7 1/3 1/7 1/8 1/5 1/1 1/6 1/6;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3/4 3/1 6/7 2/1 6/7 3/4 6/5 6/1 1/1 1/1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;3/4 3/1 6/7 2/1 6/7 3/4 6/5 6/1 1/1 1/1]&lt;br&gt;
Wt(:,1)=[1;0;0;0;0;0;0;0;0;0]&lt;br&gt;
[len,width]=size(PM); %3 x 3 matrix&lt;br&gt;
delta(:,1)=[1 1 1 1 1 1 1 1 1 1]';&lt;br&gt;
trial=100;&lt;br&gt;
&lt;br&gt;
&lt;br&gt;
for t=2:trial&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Wt1(:,t)=PM*Wt(:,t-1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;max_eig=sum(Wt1(:,t));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Wtnorm1(:,t)=Wt1(:,t)./max_eig;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;delta(:,t-1)=abs(Wt(:,t-1)-Wtnorm1(:,t));&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;if delta(:,t-1)&amp;gt;=1e-6&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;Wt(:,t)=Wtnorm1(:,t);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;else&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;CI=(max_eig-width)/(width-1);&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;weight=Wtnorm1;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;break&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;end&lt;br&gt;
end&lt;br&gt;
final_weight=weight(:,length(weight))&lt;br&gt;
disp(['After ', num2str(t),' iterations.........'])&lt;br&gt;
disp(['The pairwise comparison result is [',num2str(final_weight(1)),' ', num2str(final_weight(2)),' ', num2str(final_weight(3)),' ', num2str(final_weight(4)),' ', num2str(final_weight(5)),' ', num2str(final_weight(6)),' ', num2str(final_weight(7)),' ', num2str(final_weight(8)),' ', num2str(final_weight(9)),' ', num2str(final_weight(10)),']' ])</description>
    </item>
    <item>
      <pubDate>Fri, 23 Mar 2012 18:48:18 +0000</pubDate>
      <title>Re: Error Message "Subscripted assignment dimension mismatch"</title>
      <link>http://www.mathworks.es/matlabcentral/newsreader/view_thread/318266#870994</link>
      <author>Roger Stafford</author>
      <description>"Guan Hong " &amp;lt;jail_mage86@hotmail.com&amp;gt; wrote in message &amp;lt;jkh52e$ko5$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; Hi, I have encountered an error message "Subscripted assignment dimension mismatch" while running the m-file below. I would like to seek your expertise as I am new to MatLab. Your help will be greatly appreciated.&lt;br&gt;
&amp;gt; ......&lt;br&gt;
&amp;gt;     if delta(:,t-1)&amp;gt;=1e-6&lt;br&gt;
&amp;gt;......&lt;br&gt;
&amp;gt; final_weight=weight(:,length(weight))&lt;br&gt;
&amp;gt; ......&lt;br&gt;
- - - - - - - - - -&lt;br&gt;
&amp;nbsp;&amp;nbsp;One cause of trouble would likely be with the line:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;final_weight=weight(:,length(weight))&lt;br&gt;
&lt;br&gt;
If you arrive there with the number of columns in 'weight' less than 10, the quantity "length(weight)" will nevertheless be equal to 10 and that will produce an error message.  You shouldn't use 'length' there, use 'size(weight,2)' (or better still use 'end'.).&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;That may not be your only difficulty, though.  In the 'if' statement you have:&lt;br&gt;
&lt;br&gt;
&amp;nbsp;delta(:,t-1)&amp;gt;=1e-6&lt;br&gt;
&lt;br&gt;
My guess is that you want this to be considered true if any of the elements in delta(:,t-1) are greater than or equal to 1e-6.  However matlab will only regard it as true if all of them are greater than or equal to 1e-6.  That could cause you to do a 'break' prematurely.  You need to use the 'any' function in that case.&lt;br&gt;
&lt;br&gt;
Roger Stafford</description>
    </item>
    <item>
      <pubDate>Mon, 26 Mar 2012 08:44:12 +0000</pubDate>
      <title>Re: Error Message "Subscripted assignment dimension mismatch"</title>
      <link>http://www.mathworks.es/matlabcentral/newsreader/view_thread/318266#871198</link>
      <author>Guan Hong </author>
      <description>"Roger Stafford" wrote in message &amp;lt;jkighi$e6a$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; "Guan Hong " &amp;lt;jail_mage86@hotmail.com&amp;gt; wrote in message &amp;lt;jkh52e$ko5$1@newscl01ah.mathworks.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; Hi, I have encountered an error message "Subscripted assignment dimension mismatch" while running the m-file below. I would like to seek your expertise as I am new to MatLab. Your help will be greatly appreciated.&lt;br&gt;
&amp;gt; &amp;gt; ......&lt;br&gt;
&amp;gt; &amp;gt;     if delta(:,t-1)&amp;gt;=1e-6&lt;br&gt;
&amp;gt; &amp;gt;......&lt;br&gt;
&amp;gt; &amp;gt; final_weight=weight(:,length(weight))&lt;br&gt;
&amp;gt; &amp;gt; ......&lt;br&gt;
&amp;gt; - - - - - - - - - -&lt;br&gt;
&amp;gt;   One cause of trouble would likely be with the line:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  final_weight=weight(:,length(weight))&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; If you arrive there with the number of columns in 'weight' less than 10, the quantity "length(weight)" will nevertheless be equal to 10 and that will produce an error message.  You shouldn't use 'length' there, use 'size(weight,2)' (or better still use 'end'.).&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;   That may not be your only difficulty, though.  In the 'if' statement you have:&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;  delta(:,t-1)&amp;gt;=1e-6&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; My guess is that you want this to be considered true if any of the elements in delta(:,t-1) are greater than or equal to 1e-6.  However matlab will only regard it as true if all of them are greater than or equal to 1e-6.  That could cause you to do a 'break' prematurely.  You need to use the 'any' function in that case.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; Roger Stafford&lt;br&gt;
&lt;br&gt;
Thank you Roger Stafford for the advice. I've solved the error. Really appreciate your help. =)</description>
    </item>
  </channel>
</rss>
