How to write it in a loop?

조회 수: 1 (최근 30일)
parag gupta
parag gupta 2019년 3월 20일
댓글: Walter Roberson 2019년 3월 21일
a = 2
b = 3
p1(1) = a.b
p1(2) = a.b^2
p2(1) = a^2.b
p2(2) = a^2.b^2
.......i.e pi(j) = 2^i * 3^j where i from 1 to 4 and j from 1 to 5
Could someone please tell how to write this in a 'for' loop?

답변 (1개)

Walter Roberson
Walter Roberson 2019년 3월 20일
Hint:
Q17(1) = 18.5 - 82/19;
for K = 2 : 157
Q17(K) = Q17(K-1) + 82/19;
end
is equivalent to Q17(K) = 18.5 + 82/19*K
  댓글 수: 2
parag gupta
parag gupta 2019년 3월 20일
편집: parag gupta 2019년 3월 20일
A = zeros(4,5);
for i = 1:4
for j = 1:5
A(i,j) = 2^i*3^j
end
end
I thought to write like this.Is this wrong?
Walter Roberson
Walter Roberson 2019년 3월 21일
Looks plausible.

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

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by