how save the calculated values ​​from the loop one after the other in a vector ?

6 views (last 30 days)
This loop should calculate the dwell time and the sum function for me. For example, a time from zero to 46 is determined by the loop. How can I save these numbers in a vector / matrix with one column and several rows? Unfortunately, I am not very fit in matlab. I would be happy if someone could help.
The dwell time should be calculated using the Euler method
clear all
clc
V = input('Please enter the volume of the stirred tank in m³: ');
Vs = input('Please enter the volume flow in l / s: ');
c_zu = input('Please enter the initial concentration in mol / l: ');
h = input('Please enter the time step h in min: ');
c_zu = c_zu*1000;
Vs= Vs*0.06; % volume flow in m³/min
t= 0; %time in min
c= 0; %Start concentration in mol/m³
k = 0;
tau= V/Vs; % tau= volum /Volum flow
Abbr = 10^(-3.6);
F = 0;
c_Ab = 0;
for i = 1:1000
t= t+ h;
dcdt=1/tau*(c_zu- c_Ab);
c = c+ dcdt * h;
F = c_Ab/c_zu;
k = k+1;
if c_zu-c_Ab <= Abbr
break
else
c_Ab = c;
end
Vektor_c_Ab(i:1) = c_Ab;
Vektor_t(i:1) = t;
Vektor_F(i:1) = F;
end
Vektor_c_Ab
Vektor_t
Vektor_F
k
g = plot(Vektor_F,Vektor_t); grid on;

Accepted Answer

VBBV
VBBV on 4 Nov 2021
Vektor_c_Ab(i) = c_Ab;
Vektor_t(i) = t;
Vektor_F(i) = F;
Use the loop iterator index variable

More Answers (0)

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Products

Community Treasure Hunt

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

Start Hunting!