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

조회 수: 2(최근 30일)
Aryo Aryanapour 2021년 11월 4일
댓글: Aryo Aryanapour 2021년 11월 5일
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;

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

### 채택된 답변

VBBV 2021년 11월 4일
Vektor_c_Ab(i) = c_Ab;
Vektor_t(i) = t;
Vektor_F(i) = F;
Use the loop iterator index variable
##### 댓글 수: 1표시숨기기 없음
Aryo Aryanapour 2021년 11월 5일
It works now. Thanks alot

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

### Community Treasure Hunt

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

Start Hunting!