IF statement to fill a cell array base on conditions
3 views (last 30 days)
Show older comments
I have an ODE function with time dependent variables, one of the time dependent variable I am trying to pass throug the equation is volume. I want to set a an if statement that will fill a cell array that contains volume change over time. What I am have trouble with is writing the proper if statement.
My goal is to change volume for a certain amount of time, in my case I am changing volume until I meet a threshold, then stay constant at that threshold for another prescribed time, then when I crossed a certain depth I want to change volume again until I meet the seond threshold. Once I create this cell array, I wan to pass it to my function.
Here is my code:
DEPTH=y(1);
%% Calculating Displaced Volume as a function of flowrate and time
%cubic meter
VBD_State=cell(length(time),1);
pumprate=23.3/1000000;
total_oil=2600/1000000;
new_total_oil=1300;
for b = 1:length(time)
if displaced_volume(time(b),pumprate)<=total_oil
VBD_State{b,1}=displaced_volume(time(b),pumprate);
end
if DEPTH ==900 && displaced_volume(time(c),pumprate)<=new_total_oil
VBD_State{b,1}=displaced_volume(time(c),pumprate);
else
VBD_State{(b),1}=total_oil;
end
end
end
0 Comments
Answers (2)
Ayush Gupta
on 2 Sep 2020
Let’s say the two-volume threshold are volume_threshold1 and volume_threshold2, it can be done like this. Refer to the following code:
if(depth < depth_threshold)
if(current_volume < volume_threshold1)
change volume or do whtatever
end
else
if(current volume < colume_threshold2)
change the volume accordingly
end
end
And change the symbols accordingly to fit it.
0 Comments
See Also
Categories
Find more on Ordinary Differential Equations in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!