help-octave
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Two operations in a single statement ?


From: CdeMills
Subject: Two operations in a single statement ?
Date: Mon, 10 Jan 2011 06:45:42 -0800 (PST)

Hello, 

I would like to construct a block matrix from elementary blocks. F.i:

idx = [2 3  5];
C= [1 2 3; 2 4 5; 3 5 9];

D = zeros(5, 5); D(idx, idx) = C;
D =

   0   0   0   0   0
   0   1   2   0   3
   0   2   4   0   5
   0   0   0   0   0
   0   3   5   0   9

A possible way to implement that is through an internal function:
function y = mypad(x, idx)
y = zeros(max(idx));
y(idx, idx) = x;
endfunction

I looked about ways to implement this as an inline function, but there is no
syntax to have two statements inside such function. Any idea ? Is there an
equivalent of the C construct 
(statement_1, statement_2)
which evaluate as the LHS of statement_2 ?

Regards

Pascal

-- 
View this message in context: 
http://octave.1599824.n4.nabble.com/Two-operations-in-a-single-statement-tp3207291p3207291.html
Sent from the Octave - General mailing list archive at Nabble.com.


reply via email to

[Prev in Thread] Current Thread [Next in Thread]