<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0">
  <channel>
    <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242702</link>
    <title>MATLAB Central Newsreader - averaging vectors of different dimensions</title>
    <description>Feed for thread: averaging vectors of different dimensions</description>
    <language>en-us</language>
    <copyright>&amp;copy;1994-2012 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.com/images/membrane_icon.gif</url>
    </image>
    <item>
      <pubDate>Mon, 19 Jan 2009 23:24:38 -0500</pubDate>
      <title>averaging vectors of different dimensions</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242702#622623</link>
      <author>perfreem@gmail.com</author>
      <description>hello,&lt;br&gt;
&lt;br&gt;
i am tryin to average together several columns of different matrices,&lt;br&gt;
each column of slightly different sizes (difference might be one or&lt;br&gt;
two elements).&lt;br&gt;
for example, my columns a, b, c might be:&lt;br&gt;
&amp;nbsp;&amp;nbsp;a = my_mat1(:, 2); # size 10&lt;br&gt;
&amp;nbsp;&amp;nbsp;b = my_mat2(:, 2); # size 12&lt;br&gt;
&amp;nbsp;&amp;nbsp;c = my_mat3(:, 2); # size 11&lt;br&gt;
&lt;br&gt;
i want to make a new vector d that contains the averages of all their&lt;br&gt;
values. the first 10 values can be averaged, then for the 11th i want&lt;br&gt;
to have the average of b and c's values, and for the 12 value i only&lt;br&gt;
want c's value.&lt;br&gt;
&lt;br&gt;
is there an easy way to do this? a simple: a' + b' + c' ./ 3 does not&lt;br&gt;
work because a b and c are all different sizes....&lt;br&gt;
&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;thank you.</description>
    </item>
    <item>
      <pubDate>Tue, 20 Jan 2009 00:10:04 -0500</pubDate>
      <title>Re: averaging vectors of different dimensions</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242702#622627</link>
      <author>Sadik </author>
      <description>perfreem@gmail.com wrote in message &amp;lt;d54e80af-5e1c-4601-9f1a-b7742ffb268a@g38g2000yqn.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; hello,&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; i am tryin to average together several columns of different matrices,&lt;br&gt;
&amp;gt; each column of slightly different sizes (difference might be one or&lt;br&gt;
&amp;gt; two elements).&lt;br&gt;
&amp;gt; for example, my columns a, b, c might be:&lt;br&gt;
&amp;gt;   a = my_mat1(:, 2); # size 10&lt;br&gt;
&amp;gt;   b = my_mat2(:, 2); # size 12&lt;br&gt;
&amp;gt;   c = my_mat3(:, 2); # size 11&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; i want to make a new vector d that contains the averages of all their&lt;br&gt;
&amp;gt; values. the first 10 values can be averaged, then for the 11th i want&lt;br&gt;
&amp;gt; to have the average of b and c's values, and for the 12 value i only&lt;br&gt;
&amp;gt; want c's value.&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt; is there an easy way to do this? a simple: a' + b' + c' ./ 3 does not&lt;br&gt;
&amp;gt; work because a b and c are all different sizes....&lt;br&gt;
&amp;gt; &lt;br&gt;
&amp;gt;     thank you.&lt;br&gt;
&lt;br&gt;
How about this one [I believe in the text you have written c instead of b, because in the code, it seems that it is b whose length is 12]:&lt;br&gt;
&lt;br&gt;
([a;0;0]+b+[c;0])./[3*ones(length(a),1);2;1]</description>
    </item>
    <item>
      <pubDate>Tue, 20 Jan 2009 03:15:21 -0500</pubDate>
      <title>Re: averaging vectors of different dimensions</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242702#622642</link>
      <author>perfreem@gmail.com</author>
      <description>On Jan 19, 7:10=A0pm, &quot;Sadik &quot; &amp;lt;sadik.h...@gmail.com&amp;gt; wrote:&lt;br&gt;
&amp;gt; perfr...@gmail.com wrote in message &amp;lt;d54e80af-5e1c-4601-9f1a-b7742ffb2...=&lt;br&gt;
@g38g2000yqn.googlegroups.com&amp;gt;...&lt;br&gt;
&amp;gt; &amp;gt; hello,&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; i am tryin to average together several columns of different matrices,&lt;br&gt;
&amp;gt; &amp;gt; each column of slightly different sizes (difference might be one or&lt;br&gt;
&amp;gt; &amp;gt; two elements).&lt;br&gt;
&amp;gt; &amp;gt; for example, my columns a, b, c might be:&lt;br&gt;
&amp;gt; &amp;gt; =A0 a =3D my_mat1(:, 2); # size 10&lt;br&gt;
&amp;gt; &amp;gt; =A0 b =3D my_mat2(:, 2); # size 12&lt;br&gt;
&amp;gt; &amp;gt; =A0 c =3D my_mat3(:, 2); # size 11&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; i want to make a new vector d that contains the averages of all their&lt;br&gt;
&amp;gt; &amp;gt; values. the first 10 values can be averaged, then for the 11th i want&lt;br&gt;
&amp;gt; &amp;gt; to have the average of b and c's values, and for the 12 value i only&lt;br&gt;
&amp;gt; &amp;gt; want c's value.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; is there an easy way to do this? a simple: a' + b' + c' ./ 3 does not&lt;br&gt;
&amp;gt; &amp;gt; work because a b and c are all different sizes....&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; &amp;gt; =A0 =A0 thank you.&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; How about this one [I believe in the text you have written c instead of b=&lt;br&gt;
, because in the code, it seems that it is b whose length is 12]:&lt;br&gt;
&amp;gt;&lt;br&gt;
&amp;gt; ([a;0;0]+b+[c;0])./[3*ones(length(a),1);2;1]&lt;br&gt;
&lt;br&gt;
hi sadik,&lt;br&gt;
&lt;br&gt;
thanks for your reply.&lt;br&gt;
&lt;br&gt;
i am talking about the general case here though, the a, b, c was just&lt;br&gt;
an example. i want to do this for n-many different vectors of all&lt;br&gt;
potentially slightly different sizes...</description>
    </item>
    <item>
      <pubDate>Tue, 20 Jan 2009 06:52:01 -0500</pubDate>
      <title>Re: averaging vectors of different dimensions</title>
      <link>http://www.mathworks.com/matlabcentral/newsreader/view_thread/242702#622671</link>
      <author>Bruno Luong</author>
      <description>% Data&lt;br&gt;
a=rand(10,1);&lt;br&gt;
b=rand(12,1);&lt;br&gt;
c=rand(11,1);&lt;br&gt;
v={a b c};&lt;br&gt;
&lt;br&gt;
% Algo&lt;br&gt;
m=max(cellfun(@length,v));&lt;br&gt;
n=length(v);&lt;br&gt;
V=zeros(m,n);&lt;br&gt;
mask=zeros(m,n);&lt;br&gt;
for i=1:length(v)&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;vi=v{i};&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;V(1:length(vi),i)=vi;&lt;br&gt;
&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;mask(1:length(vi),i)=ones(size(vi));&lt;br&gt;
end&lt;br&gt;
&lt;br&gt;
MeanV = sum(V.*mask,2)./sum(mask,2)&lt;br&gt;
&lt;br&gt;
% Bruno</description>
    </item>
  </channel>
</rss>

