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!