필터 지우기
필터 지우기

Info

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

for-loop in a for-loop

조회 수: 2 (최근 30일)
Furkan Karaman
Furkan Karaman 2020년 11월 25일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello,
I want to create a matrix by using a for-loop in a for loop, below you can see my programm. Can anyone tell me where my mistake is?
n=[3 10 30 100];
p = normcdf([-1 1 -2 2 -3 3]);
gamma(1)=p(2)-p(1)
gamma(2)=p(4)-p(3)
gamma(3)=p(6)-p(5)
c=zeros(3,4);
for j=1:4
for i=1:3
c[i][j]=tinv((1+gamma(i))/(2*n(j))-1));
end
end
  댓글 수: 2
KALYAN ACHARJYA
KALYAN ACHARJYA 2020년 11월 25일
Can anyone tell me where my mistake is?
Here is the first mistake
c[i][j]=tinv((1+gamma(i))/(2*n(j))-1));
Correct Way (MATLAB allows this way 2D indexing)
c(i,j)=....
There may be more coding issue, debug ..debug...great way of learning!
Good Luck
KSSV
KSSV 2020년 11월 25일
Read about Array indexing in MATLAB. You will index a matrix using A(i,j)

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by