I'm trying to make a for-end loop that outputs a complete table of the variables t and y.
조회 수: 1 (최근 30일)
이전 댓글 표시
for t=1:100
y=1-exp(-t/50);
table(t,y)
end
I'm trying to make a for-end loop that outputs a complete table of the variables t and y. However, when I do this the way I think it would work, it pumps out 100 different, individual tables.
These are my instructions. Using a for-end loop, create two vectors and display in a table: i. T contains all integers between 1 and 100 ii. Y contains 100 elements where each element is Yn=1-e-T/50
Is there a way to make a single table? I don't really care about labels. I'm struggling to figure out how to go about doing this.
댓글 수: 0
채택된 답변
bio lim
2016년 12월 3일
Try this:
for t=1:100
y(t)=1-exp(-t/50);
end
t = 1:100;
A = [t' y'];
T = array2table(A,...
'VariableNames',{'t','y'})
Output:
T =
t y
___ ________
1 0.019801
2 0.039211
3 0.058235
4 0.076884
5 0.095163
6 0.11308
7 0.13064
8 0.14786
9 0.16473
10 0.18127 ....
댓글 수: 0
추가 답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Matrix Indexing에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!