Problem with overwriting values in vector

6 vues (au cours des 30 derniers jours)
Paulina Urban
Paulina Urban le 9 Fév 2019
Commenté : Paulina Urban le 9 Fév 2019
Hello,
my problem is with overwritting - i don't know how to overwrite vectors and save only some values. I'm solving ode ( this ode is written by me it is not ode45 or ode23 or other matlab already odefile) where i will have many values and in big netwroks i will have problem with memory - because of this i want to save only some values (for example every 4 value)
Code example of ode:
X(1) = 0.6;
Y(1)= 0.2;
licz = 1;
for tt = 1:0.05:10
l = 1;
X(l+1) = X(l) + ((X(l) *a)+(Y(l)*b));
Y(l+1) = Y(l) + (X(l)*c);
b=1;
if mod(licz,3) == 0
vector1(b) = X(l+1)
vector2(b) = Y(l+1)
end
licz=licz+1;
l=l+1
end
What i want is how to overwrite values in vector for example:
v = zeros(1,2)
step1 v = [1,0]
step2 v = [1,2]
step3 v=[2,3] (value 2 from step 2 is now on first place in vector and on second place is new value)
  2 commentaires
madhan ravi
madhan ravi le 9 Fév 2019
What’s your desired output from the above code ? State it explicitly.
Paulina Urban
Paulina Urban le 9 Fév 2019
The desired output from the code should be vector1 and vector2 which will have values calculated by these 2 equations:
X(l+1) = X(l) + ((X(l) *a)+(Y(l)*b));
Y(l+1) = Y(l) + (X(l)*c);
Because I will work on large networks if i will write from each iteration values calculated by this two equations my memory will give an error. Because of this i need to write for example after each iteration which mod(iteration number,3) == 0 and save values solved in this iteration in a vectors.
About this equations, I'm giving first value, second value is calculated, third value is calculated (first value we can delete), fourth value is calculated (second value is calculated). I always need previous value to calcualte next value ( if I'm on iteration i then I need value from previous step i-1 ) - here i think is the problem that I can't find out how to solve it :(

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Produits


Version

R2018a

Community Treasure Hunt

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

Start Hunting!

Translated by