Path: news.mathworks.com!not-for-mail
From: <HIDDEN>
Newsgroups: comp.soft-sys.matlab
Subject: How can I use plus operator on dataset element?
Date: Mon, 9 Nov 2009 10:46:01 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 26
Message-ID: <hd8rt9$9r6$1@fred.mathworks.com>
Reply-To: <HIDDEN>
NNTP-Posting-Host: webapp-03-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1257763561 10086 172.30.248.38 (9 Nov 2009 10:46:01 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 9 Nov 2009 10:46:01 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 2083920
Xref: news.mathworks.com comp.soft-sys.matlab:583507


Does anyone know how to use operators such as 'plus' with elements of a datest?

I want to do the following:

A is a dataset of size (m,5).  
B=zeros(1,5)

for i =1:m
 for j=1:5
     B(1,j)=B(1,j)+A(i,j);
  end;
end;

This generates an error an error message because I can't use the operator 'plus' with an element of a dataset.  MATLAB seems to want me to refer to each column in dataset A like this:

for i=1:m
   B(1,1)=B(1,1)+A.Var1(i)
end

But this isn't convenient if I have to perform the same operation on lots of columns.

Is there a way I can use the plus operator on a dataset?

Many thanks,

Richard.