Index exceeds matrix dimensions error?

1 回表示 (過去 30 日間)
arian hoseini
arian hoseini 2022 年 1 月 11 日
編集済み: Matt J 2022 年 1 月 11 日
L =[1 2 0.1
1 4 0.05
1 5 0.08
2 3 0.05
2 4 0.05
2 5 0.1
2 6 0.07
3 5 0.12
3 6 0.02
4 5 0.2
5 6 0.3 ]
ln = L(:,1);
rn = L(:,2);
X = L(:,3);
Q=[1;2;3;4;5;6]
for i = ln
j = rn
Pt(i,j)=(Q(i)-Q(j))/X(i,j); %Transmission power
end
the answer im looking for is pt(1,2),pt(1,4),pt(1,5),pt(2,3),pt(2,4),pt(2,5),pt(2,6),pt(3,5),pt(3,6),pt(4,5),pt(5,6)
i should have 11 pt but i get Index exceeds matrix dimensions error? and believe me i tried many things but still have the problem..so help me please..
  2 件のコメント
KSSV
KSSV 2022 年 1 月 11 日
To have 11 pt, your should have 12 Q's. But you have only 6 here. Rethink on your problem.
arian hoseini
arian hoseini 2022 年 1 月 11 日
so thats the problem but i dont need 12 Q's you know for example pt(1,2)=(Q(1)-Q(2))/X(1,2)
Q(1)=1,Q(2)=2,X(1,2)=0.1....
or pt(2,6)=(Q(2)-Q(6))/X(2,6)......Q(2)=2,Q(6)=6,X(2,6)=0.07

サインインしてコメントする。

採用された回答

Matt J
Matt J 2022 年 1 月 11 日
編集済み: Matt J 2022 年 1 月 11 日
Pt=( L(:,1)-L(:,2) )./L(:,3)

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

製品


リリース

R2016b

Community Treasure Hunt

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

Start Hunting!

Translated by