Solving equation with increasing value by multiplication
이전 댓글 표시
Hello, I am trying to create a code to calculate the area of a triangle with a range of length. And these length number are twice the previous number. Basically, first is 2, then 4, 8, 16, 32, 64, 128. Its breadth stays the same.
Code.
a =[1:???:128]
for i=1:length(a)
y=a(i)*100/2
end
I appreciate all your help in advance.
답변 (2개)
James Tursa
2018년 3월 16일
a = 2.^(1:7);
Faith Bagire
2020년 9월 4일
The best way that worked for me is using a while loop!
a=1;
while a < 128
y=a*100/2
a=a*2;
end
카테고리
도움말 센터 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!