Info

この質問は閉じられています。 編集または回答するには再度開いてください。

I keep getting the error Subscript indices must either be real positive integers or logicals.

1 回表示 (過去 30 日間)
Michele  Thompson
Michele Thompson 2017 年 9 月 30 日
閉鎖済み: MATLAB Answer Bot 2021 年 8 月 20 日
theta=linspace(-pi,pi,500);
P=[269.2 15913 8964 2421];
E1=0.206;
Nth=length(theta), NP=length(P);
r1=zeros(Nth,NP);
for i=1:Nth
c=1-(E1*cos(theta(i)));
for j=1:NP
r1=(E1*P(j))/c;
end
end

回答 (1 件)

Walter Roberson
Walter Roberson 2017 年 9 月 30 日
That code executes without difficulty for me. However you are overwriting all of r1 every iteration of j and every iteration of i. Perhaps you want
r1(i, j) = (E1*P(j))/c;

この質問は閉じられています。

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by