initial condition and coding

2 vues (au cours des 30 derniers jours)
Basheer
Basheer le 30 Juil 2015
Réponse apportée : Basheer le 1 Août 2015
Hello guys, I have the 1D channel as shown in the pic. I use finite volume method to code and I depend on number of cells (m) in my coding. I would like to add the water depth initial condition based on the distance (x) not (m), so the water depth is h=0.75 when x<15.5 else it is zero.
in the same time I wanna keep the using of the definition of h(i),as vector, my previous work without of interact of x ,of other cases,is:
h=zeros(1,m);
for i=1:m;
if (i>m/2)
h(i)=0.000001;
else
h(i)=1;
end
end
do u have any suggestions? thanks in advance.

Réponses (1)

Basheer
Basheer le 1 Août 2015
I did it, thx
x=0; for i=1:m; if x<=25.5; Zb(i)=0; elseif x>25.5 && x<=28.5; Zb(i)=Zb(i-1)+dx*0.1333; elseif x>25.5 && x<=31.5; Zb(i)=Zb(i-1)+dx*(-0.1333); elseif x>31.5; Zb(i)=0; end x=x+dx; end

Catégories

En savoir plus sur Mathematics dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by