Need some help with simple code in matlab

Status
Not open for further replies.

mango1986

Newbie level 2
Joined
Mar 5, 2008
Messages
2
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
1,292
Hi,
I want to know the matlab code that
if H=[ 1 2
3 4
5 6
7 8
9 0]
how to get H=[ 3 4
5 6
7 8
9 0]
thx!
 

some code in matlab

H=[ 1 2
3 4
5 6
7 8
9 0]

>> H1=H(2:5,: )
result:

H1=[ 3 4
5 6
7 8
9 0]
 

Re: some code in matlab

thx hm sheng!
may I ask one more question?
if I want to get all subset of H
e.g.H[ 1 2 or H[ 1 2
5 6 3 4
7 8 7 8
9 0] 9 0] ......................and so on

how can I write the matlab code ?

Thx!
 

some code in matlab

H = [1 2
3 4
5 6
7 8
9 0];
for i = 1:5
H1 = H;
H1(i,: ) = [];
HH,:,i) = H1;
end

result:
>> HH

HH,:,1) =

3 4
5 6
7 8
9 0


HH,:,2) =

1 2
5 6
7 8
9 0


HH,:,3) =

1 2
3 4
7 8
9 0


HH,:,4) =

1 2
3 4
5 6
9 0


HH,:,5) =

1 2
3 4
5 6
7 8

>>
Is this what you want?
 

Status
Not open for further replies.

Similar threads

Cookies are required to use this site. You must accept them to continue using the site. Learn more…