Path: news.mathworks.com!not-for-mail
From: "Sadik " <sadik.hava@gmail.com>
Newsgroups: comp.soft-sys.matlab
Subject: Re: How to assign a vector to a structure?
Date: Mon, 15 Jun 2009 04:20:17 +0000 (UTC)
Organization: The MathWorks, Inc.
Lines: 23
Message-ID: <h14i61$4b3$1@fred.mathworks.com>
References: <h141it$d34$1@fred.mathworks.com> <h14479$o0f$1@fred.mathworks.com> <h14goh$6lc$1@fred.mathworks.com>
Reply-To: "Sadik " <sadik.hava@gmail.com>
NNTP-Posting-Host: webapp-05-blr.mathworks.com
Content-Type: text/plain; charset="ISO-8859-1"
Content-Transfer-Encoding: 8bit
X-Trace: fred.mathworks.com 1245039617 4451 172.30.248.35 (15 Jun 2009 04:20:17 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Mon, 15 Jun 2009 04:20:17 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 1666517
Xref: news.mathworks.com comp.soft-sys.matlab:547428


You are right, sorry. This one should work:

s = struct('number', mat2cell((1:10)',ones(10,1),1), 'bankID', mat2cell([ones(5,1);2*ones(5,1)],ones(10,1),1));



"Kian " <kian.torab@utah.edu> wrote in message <h14goh$6lc$1@fred.mathworks.com>...
> Sadik,
> 
> Thanks for your response, but that doesn't achieve what I wanted to do. What you did is done by:
> 
> s.number = numbers';
> s.bankID = bankID';
> 
> I want the following:
> 
> s(1).number = 1
> s(3).bankID = 1
> s(7).bankID = 2
> and so on...
> 
> Thanks!
> Kian