IF statement to fill a cell array base on conditions
4 views (last 30 days)
Show older comments
Jestoni Orcejola on 26 Aug 2020
Answered: Jestoni Orcejola on 2 Sep 2020
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:
%% Calculating Displaced Volume as a function of flowrate and time
for b = 1:length(time)
if DEPTH ==900 && displaced_volume(time(c),pumprate)<=new_total_oil
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
if(current volume < colume_threshold2)
change the volume accordingly
And change the symbols accordingly to fit it.
Find more on Programming 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!