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

dpb
dpb 2019년 8월 19일
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?
Antonio Grivas
Antonio Grivas 2019년 8월 19일
편집: Antonio Grivas 2019년 8월 19일
Num_of_Banks is always 4 (or I will change it at eg 100 for the simulations) but it will always be the same from the begining
Vars to rand = Loans / Assets / Risk / RWAs ... (some of them will be computed with for loops eg the RWAs)
I will repeat it 100 (MC simulation) times to regress it after that
Thanks in advance

댓글을 달려면 로그인하십시오.

 채택된 답변

dpb
dpb 2019년 8월 19일

1 개 추천

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

Antonio Grivas
Antonio Grivas 2019년 8월 20일
편집: Antonio Grivas 2019년 8월 20일
What the prog does is not fully random (sorry if I didn't say that)
It takes num of banks
For each bank set (=4) sets a rand set of caps and what each bank has to pay to other banks
Uses gras algo (and others) to make the loan matrix
makes some results about digraphs characteristics / ratings / banks default
Puts the result in a matrix row.
For 1 time it creates a table with the results.
(It has many for loops [17 different] / other functions ..)
What I can't connect is how to make this:
run ->give results at 1st time
run again - >give results next time
My first try was auful !!
My 10th try was misserable !!
My after a week (I have read many documents but nothing was common or could not connect them with what I have)
My last try was a function but I don't have a clue where to put the iteration to repeat the process. I have tryed inside the function (set it at 2 repeats -> gives a result that i already know (I have it ) and an 'ans' which is the same (does not look like it had repeat it)).
I used it inside the function (T(? , ?) both cases for ter and :) and it returns the result that I have and errors
I really thank you for your answer and I hope that I will not look aggresive after you read this
Next try that worked??
I put a "for i=1:5" at the beginning
Added at the end a table column for the iter
I had to convert it to array "table2array"
Worked !!!!

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

질문:

2019년 8월 19일

편집:

2019년 8월 20일

Community Treasure Hunt

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

Start Hunting!

Translated by