matlab indexing issue with range -pi:pi

조회 수: 3 (최근 30일)
Chetan Fadnis
Chetan Fadnis 2022년 5월 20일
댓글: Walter Roberson 2022년 5월 26일
I have following code, which i need to plot for alpha versus theta.
But i am unable to index it properly.
Kindly help. Thanks in anticipation. Regards
amin=0.2;
for theta=-3.1416:1.5708:3.1416 (-pi:pi/2:pi)
for gamma=0:0.5:3
phi=amin-(-pi/2);
alpha((?),(gamma*2)+1)=(1-amin)*(((sin(theta-phi)+1)/2).^gamma)+amin;
end
end

채택된 답변

VBBV
VBBV 2022년 5월 20일
편집: VBBV 2022년 5월 20일
amin=0.2;
theta = -pi:pi/2:pi;
gamma=0:0.5:3;
for T=1:length(theta)
for G = 1:length(gamma)
phi=amin-(-pi/2);
alpha(T,G)=((1-amin)*(((sin(theta(T)-phi)+1)/2).^gamma(G))+amin)/((gamma(G)*2)+1);
end
end
plot(theta,alpha)
xlabel('theta');ylabel('alpha')
  댓글 수: 2
Chetan Fadnis
Chetan Fadnis 2022년 5월 26일
Thank you,
But the maximum values i.e. at -pi and at pi should be 1.
and what will be the case, if amin is also variable between 0 and 1.
Walter Roberson
Walter Roberson 2022년 5월 26일
The maximum value is 1 exactly and it is being plotted. You need to ylim([0 1.1])

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Gamma Functions에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by