array fetching and placing in matrix
Show older comments
I have a matrix c = [0 0 0; 0 0 0; 0 0 0] from the command c=zeros(3,3). My array p=[12,10,11,13,8,9,5]; I need to get array in c and my final value of c should be [12,10,11;9,13,8;0,0,5]. First 3 array value should be placed in first row of c, in the second row of c, it has to look the minimum value in the first row (min value =10) corresponding column it has to place the fourth value in array. Similarly fifth and sixth value in array p is placed. now in the third row of matrix c, first two rows of c has to be added to get the minimum value. after the summation minimum value is in third column so the seventh value in the array p is placed in third column of matrix c. This procedure has to be done irrespective of the array size and matrix. kindly suggest.
2 Comments
Guillaume
on 6 Sep 2016
I don't understand your algorithm. Why, when the minimum of the first row is 10, do you select the 6th value (equal to 9) of p to place in C(2, 1)?
Bathrinath
on 6 Sep 2016
Accepted Answer
More Answers (0)
Categories
Find more on Arithmetic Operations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!