필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

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

조회 수: 1 (최근 30일)
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