sharing values of elements in a matrix

Hi All, I've attached my questions for your reference - It was hard to paste here.

5 Comments

How it was calculated?
1 to 2 = 0
1 to 3 = 12.09
1 to 4 = 11.74
2 to 3 = 11.74
Hi Darova, I derived
W = Z= Y=
[0; [0.4696; [1 2 0 0;
0; 0.3841; 1 3 2 0;
0; 0.3672; 1 4 3 2;
28; 0.4317; 1 3 0 0;
0; 0.4049; 1 2 3 0;
0; 0.4049; 1 4 3 0;
25; 0.4696; 1 4 0 0;
0; 0.3841; 1 3 4 0;
0; 0.3672; 1 2 3 4;
25; 0.4696; 2 3 0 0;
0; 0.3841; 2 1 3 0;
0; 0.3672; 2 1 4 3;
15; 0.4049; 2 1 4 0;
14; 0.4049; 2 3 4 0;
0; 0.3530; 2 1 3 4;
0; 0.3530; 2 3 1 4;
25; 0.4696; 3 4 0 0;
0; 0.3841; 3 1 4 0;
0;] 0.3672;] 3 2 1 4;]
Using Y as a reference where to put the product values of W*Z into initial X:
X =
[0 0*0.4696=0 28*0.4317=12.09 25*0.4696=11.74;
0*0.4696=0 0 25*0.4696=11.74 15*0.4049+14*0.4049=11.74;
28*0.4317=12.09 25*0.4696=11.74 0 25*0.4696=11.74;
25*0.4696=11.74 15*0.4049+14*0.4049=11.74 25*0.4696=11.74 0;];
hence, initial X is:
X =
[ 0 0 12.09 11.74;
0 0 11.74 11.74;
12.09 11.74 0 11.74;
11.74 11.74 11.74 0;]
How to get matrix of 4x4 from
% length of W is 19 elements
W =
0
0
0
28
0
0
25
0
0
25
0
0
15
14
0
0
25
0
0
JL's incorrectly posted "Answer" moved here and formatted correctly:
Hi Darova, what I did was first multiplied W.*Z to get X0
Then I used this code from star strider
for k = 1:size(Y,1)
[~,Zc] = find(Y(k,:) ~= 0, 1, 'last'); % Last Non-Zero Column
Z2(k,:) = Y(k,Zc); % Element Of Last Non-Zero Column
end
Z = accumarray([Z2 Y(:,1)], X0)
Z1 = [Z, zeros(size(Z,1),1 )];
Z2 = [Z.'; zeros(1,size(Z,1 ))];
Znew = Z1 + Z2
With this code, I get
X =
[ 0 0 12.09 11.74;
0 0 11.74 11.74;
12.09 11.74 0 11.74;
11.74 11.74 11.74 0;]
I think your question is too hard for me

Sign in to comment.

Answers (0)

Categories

Find more on Mathematics in Help Center and File Exchange

Tags

Asked:

JL
on 8 Aug 2019

Commented:

on 9 Aug 2019

Community Treasure Hunt

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

Start Hunting!