matlab table from for loops
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Antonio Grivas
am 19 Aug. 2019
Bearbeitet: Antonio Grivas
am 20 Aug. 2019
for iter = 1:2
Num_of_Banks = 4
Initial_Capitals = [ randi([0 100],Num_of_Banks,1) ]
Total_initial_caps = sum(Initial_Capitals)
end
This will set Num_of_Banks = always 4 and Initial_Capitals = rand
How can I create a table from X num of iterations (Prob = everything that I have tried til now) and store correctly the results?
Trying to make sth like this:
Num_of_Banks Initial_Capitals
4 amount 1
4 amount 2
4 amount 3
... ...
(My prog has almost 50 variables to be added so this is a small part of it)
Will appreciate your answers
(R2016a version)
2 Kommentare
dpb
am 19 Aug. 2019
Do you really intend for the #Banks variable to be constant for some N rows or is that also a random or otherwise known number?
Is the initial amount for each one of the random values?
Akzeptierte Antwort
dpb
am 19 Aug. 2019
A table may not be the best for this purpose but iiuc what you're asking for would be something like
Nrows=100;
Num_of_Banks=repelem(4,Nrows,1);
InitialCapital=randi([0 100],Num_of_Banks,Nrows);
Loans=randi([0 20],Num_of_Banks,Nrows);
Assets=randi([100 10000],Num_of_Banks,Nrows);
...
t=table(Num_of_Banks,InitialCapital,Loans,Assets,...);
1 Kommentar
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrix Indexing finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!