Continue to Site

Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronics Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Generate combination of elements in matlab

Status
Not open for further replies.

haisrilatha

Newbie level 5
Newbie level 5
Joined
Mar 2, 2010
Messages
9
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,354
Hi,
I have k element vector with elements {1,-1,0}.
I need to generate 3 power k combinations.
How can i generate in matlab?
Can someone suggest me logic to get it?

Expecting reply
Sri[/b]
 

kindly elaborate your question.....

Well According to your question below is the solution

if your vector v = [1 -1 0 1 0 -1 ........] with k elemnets
p = [] % Intiate p as null vector to store the value

for i = 1:1:k
power = 3^ v(i);
p = [p power];
end
 

Re: Generate combination of elements in C

Thnx for the reply.
I have a k=3 element vector {1,-1,0}
And have n nodes which can transmit any of the three elements.
I need to generate all 3^n combinations i.e with repetition allowed for the elements.
I got the code in MATLAB as
v = [1 -1 0];
n=8;
k = length(v);
m = zeros(k^n,n);
c = repmat(v( : ),k^(n-1),1);
for col = 1:int
t = reshape(c,k^col,length(c)/(k^col));
t = t';
m:),col) = t( : );
end

but i need to generate in C.
Can someone suggest me logic or algorithm to generate all the combinations in C

Regards
Sri
 

Status
Not open for further replies.

Similar threads

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Back
Top