How can I create the matrix in the photo?

2 次查看(过去 30 天)
<<
>>
dog_tab =
1.200000000000000 2.400000000000000 1.300000000000000
2.300000000000000 1.500000000000000 1.000000000000000
R =
0.200000000000000 0.400000000000000 0.300000000000000
BNdog =
4
4
nokta_ad =
4
7
11
for i=1:2
Kll = [dog_tab(nokta_ad==BNdog(i),1)^2 R(nokta_ad==BNdog(i),1)*dog_tab(nokta_ad==BNdog(i),1)*dog_tab(nokta_ad==BNdog(i),2) R(nokta_ad==BNdog(i),2)*dog_tab(nokta_ad==BNdog(i),1)*dog_tab(nokta_ad==BNdog(i),3)
R(nokta_ad==BNdog(i),1)*dog_tab(nokta_ad==BNdog(i),1)*dog_tab(nokta_ad==BNdog(i),2) dog_tab(nokta_ad==BNdog(i),2)^2 R(nokta_ad==BNdog(i),3)*dog_tab(nokta_ad==BNdog(i),2)*dog_tab(nokta_ad==BNdog(i),3)
R(nokta_ad==BNdog(i),2)*dog_tab(nokta_ad==BNdog(i),1)*dog_tab(nokta_ad==BNdog(i),3) R(nokta_ad==BNdog(i),3)*dog_tab(nokta_ad==BNdog(i),2)*dog_tab(nokta_ad==BNdog(i),3) dog_tab(nokta_ad==BNdog(i),3)^2]
end
Kll7-4 matrix is forming. How can I create the other matrix?

采纳的回答

Andrei Bobrov
Andrei Bobrov 2017-5-5
编辑:Andrei Bobrov 2017-5-5
m = [1.2000 2.4000 1.3000
2.3000 1.5000 1.0000];
r = [0.2000 0.4000 0.3000];
K = permute(m,[2,3,1]).*permute(m,[3,2,1]).*...
(hankel([0,r(1:2)],[r(2:3),0]).*~eye(3)+eye(3)); % MATLAB >= R2016b
for MATLAB < R2016b
rr = triu(ones(3),1);
rr(rr > 0) = r;
mm = bsxfun(@times,permute(m,[2,3,1]),permute(m,[3,2,1]));
K = bsxfun(@times,mm,rr + rr.' + eye(3));

更多回答(1 个)

Santhana Raj
Santhana Raj 2017-5-5
Try making
BNdog=[4 7];
instead of [4 4]
  1 个评论
Muhendisleksi
Muhendisleksi 2017-5-5
"Index exceeds matrix dimensions.
Error in Untitled (line 10) Kll = [dog_tab(nokta_ad==BNdog(i),1)^2 R(nokta_ad==BNdog(i),1)*dog_tab(nokta_ad==BNdog(i),1)*dog_tab(nokta_ad==BNdog(i),2) R(nokta_ad==BNdog(i),2)*dog_tab(nokta_ad==BNdog(i),1)*dog_tab(nokta_ad==BNdog(i),3)" error occurred

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

标签

Community Treasure Hunt

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

Start Hunting!

Translated by