hi
I have data in the array (array size is 12) which is divided into 5 groups as shown in attached picture. Now for e.g I want to cut and move data from group 4 position (10) to group 2 position (7+1) how I do it. this picking and dropping procedure is variable in each iteration. sometimes from one group to another. but for this example, I take the data from position 10 and move it to position 8.
A=[
10 1 2
12 2 3
13 3 4
14 5 6
17 7 8
11 8 9
1 10 11
2 12 13
3 14 15
7 16 17
8 7 8
11 1 2]
when I cut data from group 4 position (10) and past on (7+1) location then it overlaps on the group 3 data. I want to place this data on position (7+1) and After this adjustment, I need to start group 3 from position (9). how I cut and past the data by maintaining the array size same without effecting the values of groups. kindly help me I will be highly thankful to you
I need as following
A=[
10 1 2
12 2 3
13 3 4
14 5 6
17 7 8
11 8 9
1 10 11
7 16 17
2 12 13
3 14 15
8 7 8
11 1 2]
with best Regards
Mudasir

4 commentaires

James Tursa
James Tursa le 21 Déc 2016
Are the sizes and locations of the groups fixed or can they vary? If they can vary, what variables do you have that store the size and location information?
Dear sir James Tursa
groups are fixed but their size may vary by iteration to iteration.
for e.g any data
A=[
10 1 2
12 2 3
13 3 4
14 5 6
17 7 8
11 8 9
1 10 11
2 12 13
3 14 15
7 16 17
8 7 8
11 1 2]
Now I want to move data of position (10) [7 16 17] on to position (8). by automatically adjusting the size of the array. means automatically the data [2 12 13] move to 9 location, and previously 9 position data move to 10. and as previously 10 positions is already transferred to position 8. 11 and 12 position rest remain same. Now group 1 consists of 4 positions. group 2 consist of 4 positions. group 3 consist 1, group 4 consist 1 and group 5 consist 2 positions. sizr of groups may vary depend on the iteration to iteration. Kindly help me sir
James Tursa
James Tursa le 21 Déc 2016
For this example, please post the desired result.
Mudasir Ahmed
Mudasir Ahmed le 21 Déc 2016
Modifié(e) : Mudasir Ahmed le 21 Déc 2016
sir results will be like
A=[
10 1 2
12 2 3
13 3 4
14 5 6
17 7 8
11 8 9
1 10 11
7 16 17
2 12 13
3 14 15
8 7 8
11 1 2]

Connectez-vous pour commenter.

 Réponse acceptée

dpb
dpb le 21 Déc 2016
Modifié(e) : dpb le 22 Déc 2016

0 votes

>> i1=10;i2=8;
>> A=[A(1:i2-1,:); A(i1,:); A(i2:i1-1,:); A(i1+1:end,:)]
A =
10 1 2
12 2 3
13 3 4
14 5 6
17 7 8
11 8 9
1 10 11
7 16 17
2 12 13
3 14 15
8 7 8
11 1 2
>> length(A)
ans =
12
>>

4 commentaires

Mudasir Ahmed
Mudasir Ahmed le 21 Déc 2016
Dear Sir
Thank you so much, sir, for your kind help. but in answer, the array is exceeding its limit which is 12 but now array size is 14.
dpb
dpb le 22 Déc 2016
Modifié(e) : dpb le 22 Déc 2016
Typo, sorry didn't catch it...the last i2 should be i1; with the error it duplicates a subset i2:i1 that shouldn't be included...I corrected the Answer.
Mudasir Ahmed
Mudasir Ahmed le 22 Déc 2016
Thank you so much, sir. Now its perfectly working. :)
Mudasir Ahmed
Mudasir Ahmed le 22 Déc 2016
Dear sir,
I send you my project code in email. kindly look my code. the issue i face in it is the size of array. in last iteration, I need one imperialist having colonies I-clny=95.

Connectez-vous pour commenter.

Plus de réponses (0)

Produits

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by