MATLAB Answers

0

app callback push button with wrong answer to plot

Asked by Ghazi Kraishan on 13 Jul 2018 at 16:31
Latest activity Commented on by Ghazi Kraishan on 14 Jul 2018 at 6:14

G'Day everyone,

How to handle the below problem: I can not get the correct answer if one of the array sample is less than a specified value, Please see below

           low = app.min.Value;
           high = app.max.Value;
           Pc_min_log = log(low)/2.31049;
           Pc_max_log = log(high)/2.31049;
           n = app.Number.Value;
           step = (Pc_max_log - Pc_min_log)/n;
           swi_model = app.Swi.Value;
           pd_model = app.Pd.Value;
           g_model = app.G.Value;
           Pc = Pc_min_log;
           i=0:1:n;
           Pc = Pc + i*step;
           Pc = exp(Pc*2.31049)
           if(Pc - pd_model > 0.1)
               Sw_Model = swi_model + (1-swi_model)*(1-exp(g_model./(log(pd_model./Pc))));       
           else
               Sw_Model = 1;  
           end       
           plot(app.Sw, Sw_Model, Pc,'LineWidth',0.4);

Appreciate your help,

Regards,

Gaz

  3 Comments

Ghazi - are you observing an error? If so, please paste the full error message so that we can see which line is throwing the error.

You are comparing a vector with a scalar. The expression in your if statement will only be true if all values in your vector fulfill the condition.

Thats my best guess what your problem is. As Geoff already stated a more detailed describtion of your problem helps to provide a correct answer.

Thanks Guys,

There is no error associated with the code it just gives the wrong results. Basically what I am trying to do is: I have one array (x) and I need to compare each element of it to a value (x1). Then the code generates another array (Y). If I change the x1 value then Y should change accordingly per the code within the if statement.

that is all,

Thanks for your help and concerns

Regards

Ghazi

Sign in to comment.

0 Answers