I'm trying to make a for-end loop that outputs a complete table of the variables t and y.

1 vue (au cours des 30 derniers jours)
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.

Réponse acceptée

bio lim
bio lim le 3 Déc 2016
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 ....

Plus de réponses (0)

Catégories

En savoir plus sur Loops and Conditional Statements dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by