Thread Subject: help! help!! help!!! me

Subject: help! help!! help!!! me

From: Jim lei

Date: 27 Dec, 2007 02:33:43

Message: 1 of 4

hello
if
x=linspace(1,100,n);
p=linspace(100,80,n-1);
how can I get A

A=[
x(1) 1 0 0 0 0 0 0...0 0;
x(2) 1 -x(2) -1 0 0 0 0...0 0;
p(1) 0 -p(2) 0 0 0 0 0...0 0;
0 0 x(3) 1 -x(3) -1 0 0...0 0;
0 0 p(2) 0 -p(3) 0 0 0...0 0;
0 0 0 0 x(4) 1 -x(4) -1...0 0;
0 0 0 0 p(3) 0 -p(4) 0...0 0;
......................................
0 0 0 0 0 0...x(i) 1 -x(i) -1...0 0;
0 0 0 0 0 0...p(i-1) 0 -p(i-1) 0 ...0 0;
........................................
0 0 0 0 0 0....x(n-1) 1 -x(n-1) -1;
0 0 0 0 0 0....p(n-2) 0 -p(n-1) 0;
0 0 0 0 0 0.... 0 0 p(n-1) 0;
]

Subject: help! help!! help!!! me

From: Jim lei

Date: 27 Dec, 2007 02:41:13

Message: 2 of 4

"Jim lei" <redlightlike@mathworks.com> wrote in message
<fkv2u7$t1i$1@fred.mathworks.com>...
> hello
> if
> x=linspace(1,100,n);
> p=linspace(100,80,n-1);
> how can I get A
>
> A=[
> x(1) 1 0 0 0 0 0 0...0 0;
> x(2) 1 -x(2) -1 0 0 0 0...0 0;
> p(1) 0 -p(2) 0 0 0 0 0...0 0;
> 0 0 x(3) 1 -x(3) -1 0 0...0 0;
> 0 0 p(2) 0 -p(3) 0 0 0...0 0;
> 0 0 0 0 x(4) 1 -x(4) -1...0 0;
> 0 0 0 0 p(3) 0 -p(4) 0...0 0;
> ......................................
> 0 0 0 0 0 0...x(i) 1 -x(i) -1...0 0;
> 0 0 0 0 0 0...p(i-1) 0 -p(i) 0 ...0 0;
> ........................................
> 0 0 0 0 0 0....x(n-1) 1 -x(n-1) -1;
> 0 0 0 0 0 0....p(n-2) 0 -p(n-1) 0;
> 0 0 0 0 0 0.... 0 0 p(n-1) 0;
> ]

Subject: help! help!! help!!! me

From: Huy

Date: 27 Dec, 2007 06:07:21

Message: 3 of 4

"Jim lei" <redlightlike@mathworks.com> wrote in message
<fkv3c9$61e$1@fred.mathworks.com>...
> "Jim lei" <redlightlike@mathworks.com> wrote in message
> <fkv2u7$t1i$1@fred.mathworks.com>...
> > hello
> > if
> > x=linspace(1,100,n);
> > p=linspace(100,80,n-1);
> > how can I get A
> >
> > A=[
> > x(1) 1 0 0 0 0 0 0...0 0;
> > x(2) 1 -x(2) -1 0 0 0 0...0 0;
> > p(1) 0 -p(2) 0 0 0 0 0...0 0;
> > 0 0 x(3) 1 -x(3) -1 0 0...0 0;
> > 0 0 p(2) 0 -p(3) 0 0 0...0 0;
> > 0 0 0 0 x(4) 1 -x(4) -1...0 0;
> > 0 0 0 0 p(3) 0 -p(4) 0...0 0;
> > ......................................
> > 0 0 0 0 0 0...x(i) 1 -x(i) -1...0 0;
> > 0 0 0 0 0 0...p(i-1) 0 -p(i) 0 ...0 0;
> > ........................................
> > 0 0 0 0 0 0....x(n-1) 1 -x(n-1) -1;
> > 0 0 0 0 0 0....p(n-2) 0 -p(n-1) 0;
> > 0 0 0 0 0 0.... 0 0 p(n-1) 0;
> > ]
>
Divide your matrix into sub-matrices, and then combine them.

%%
Ax1 = zeros(n-2,n-1);
Ax2 = zeros(n-2,n-1);
diagpos = sub2ind([n-2 n-1],1:n-2,1:n-2);

Ax1(diagpos) = x(2:end-1);
Ax1(diagpos+n-2) = -x(2:end-1);

Ax2(diagpos) = 1;
Ax2(diagpos+n-2) = -1;

% Ax = reshape(cat(1,Ax1,Ax2),[size(Ax1,1)
size(Ax1,2)+size(Ax2,2)])
Ax = zeros(n-2,2*n-2);
Ax(:,1:2:end) = Ax1;
Ax(:,2:2:end) = Ax2;

%%
Ap1 = zeros(n-2,n-1);
Ap1(diagpos) = p(1:n-2);
Ap1(diagpos+n-2) = -p(2:n-1);

Ap = zeros(n-2,2*n-2);
Ap(:,1:2:end-1) = Ap1;
%%
A = zeros(2*n-2,2*n-2);

A(2:2:end-2,:) = Ax;
A(3:2:end,:) = Ap;
A(1,[1 2]) = [x(1) 1];
A(end,end-1) = p(end);


Anh Huy Phan
RIKEN - BSI

Subject: help! help!! help!!! me

From: roberson@ibd.nrc-cnrc.gc.ca (Walter Roberson)

Date: 27 Dec, 2007 20:38:26

Message: 4 of 4

In article <fkv2u7$t1i$1@fred.mathworks.com>,
Jim lei <redlightlike@mathworks.com> wrote:

>if
>x=linspace(1,100,n);
>p=linspace(100,80,n-1);
>how can I get A

>A=[
>x(1) 1 0 0 0 0 0 0...0 0;
>x(2) 1 -x(2) -1 0 0 0 0...0 0;
>p(1) 0 -p(2) 0 0 0 0 0...0 0;
>0 0 x(3) 1 -x(3) -1 0 0...0 0;
>0 0 p(2) 0 -p(3) 0 0 0...0 0;
>0 0 0 0 x(4) 1 -x(4) -1...0 0;
>0 0 0 0 p(3) 0 -p(4) 0...0 0;
>......................................
>0 0 0 0 0 0...x(i) 1 -x(i) -1...0 0;
>0 0 0 0 0 0...p(i-1) 0 -p(i-1) 0 ...0 0;
>........................................
>0 0 0 0 0 0....x(n-1) 1 -x(n-1) -1;
>0 0 0 0 0 0....p(n-2) 0 -p(n-1) 0;
>0 0 0 0 0 0.... 0 0 p(n-1) 0;
>]

See the functions diag() and blkdiag().

Also, please use a more descriptive topic name.

Another note: when you post requesting urgent help without describing
your timeframe, then after a couple of hours, people are likely not
to reply, figuring that your deadline has likely already passed. Or
sometimes, perhaps even within the first few hours, they may choose
not to respond, with thoughts about it being irresponsible of you
to have left the task to the last minute. There is a saying,
"Your bad planning does not my emergency make."
--
   So you found your solution
   What will be your last contribution?
   -- Supertramp (Fool's Overture)

Tags for this Thread

Add a New Tag:

Separated by commas
Ex.: root locus, bode

What are tags?

A tag is like a keyword or category label associated with each thread. Tags make it easier for you to find threads of interest.

Anyone can tag a thread. Tags are public and visible to everyone.

rssFeed for this Thread

Public Submission Policy

NOTICE: Any content you submit to MATLAB Central, including personal information, is not subject to the protections which may be afforded information collected under other sections of The MathWorks, Inc. Web site. You are entirely responsible for all content that you upload, post, e-mail, transmit or otherwise make available via MATLAB Central. The MathWorks does not control the content posted by visitors to MATLAB Central and, does not guarantee the accuracy, integrity, or quality of such content. Under no circumstances will The MathWorks be liable in any way for any content not authored by The MathWorks, or any loss or damage of any kind incurred as a result of the use of any content posted, e-mailed, transmitted or otherwise made available via MATLAB Central. Read the complete Disclaimer prior to use.

Contact us at files@mathworks.com