Azzera filtri
Azzera filtri

How can I do this iteration?

4 visualizzazioni (ultimi 30 giorni)
Elia Paini
Elia Paini il 10 Lug 2021
Commentato: ANKUR KUMAR il 11 Lug 2021
Hi, I have a simple question related to a problem.
I have to make an iterative code which updates values of some hypothesized vectors, until I reach convergence.
To simplify, I have two vectors a,b with initial assumed values, then the cycle updates their values until it stops when:
, where "i" is the iteration index.
I think this can be solved with an easy code, maybe with a while cicle?
Thank you for your help!

Risposte (1)

ANKUR KUMAR il 11 Lug 2021
Modificato: ANKUR KUMAR il 11 Lug 2021
Here is the sample code using random data
threshold=0.5; % You need to change it to 1e-6 and use original data
out= -9999; % setting random data
while out<threshold
out = 1×3
0.3175 0.4034 0.6554
  2 Commenti
Elia Paini
Elia Paini il 11 Lug 2021
Thanks! But how can I save all simulated vectors in a matrix, at each iteration? In your code, "i" refers to the element of the vectors, while it should represent the column of a matrix built at every iteration.
ANKUR KUMAR il 11 Lug 2021
Updated the code.

Accedi per commentare.


Scopri di più su Particle & Nuclear Physics in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by