Path: news.mathworks.com!not-for-mail
From: "Miroslav Balda" <miroslav.nospam@balda.cz>
Newsgroups: comp.soft-sys.matlab
Subject: Re: matrix generation
Date: Sun, 8 Nov 2009 17:39:02 +0000 (UTC)
Organization: Miroslav Balda
Lines: 18
Message-ID: <hd6vnm$7u3$1@fred.mathworks.com>
References: <hd6uef$j43$1@fred.mathworks.com>
Reply-To: "Miroslav Balda" <miroslav.nospam@balda.cz>
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 1257701942 8131 172.30.248.38 (8 Nov 2009 17:39:02 GMT)
X-Complaints-To: news@mathworks.com
NNTP-Posting-Date: Sun, 8 Nov 2009 17:39:02 +0000 (UTC)
X-Newsreader: MATLAB Central Newsreader 360709
Xref: news.mathworks.com comp.soft-sys.matlab:583374


"jack j" <12mailjack@gmail.com> wrote in message <hd6uef$j43$1@fred.mathworks.com>...
> Hi,
> I want to generate a 6x4 matrix of positive integers(max value:50) such that the difference between the 3rd element and 1st element in each row is 2 and difference of 2nd and 4th row element in all rows is 3.     
> Any help?

Hi,

Does it fit you?

%   jack.m      2009-11-08
%%%%%%%%%%%%
A = zeros(6,4);
A(:,1) = ceil(48*rand(6,1));
A(:,3) = A(:,1)+2;
A(:,4) = ceil(47*rand(6,1)+3);
A(:,2) = A(:,4)-3

Mira