Effacer les filtres
Effacer les filtres

How to merge values as given index in a single array

1 vue (au cours des 30 derniers jours)
Arvind
Arvind le 28 Août 2023
Commenté : Voss le 28 Août 2023
porindex1 = find(por<=0.47); %% por<=0.5
porindex2 = find(por>0.47&por<=0.63); %% por>0.47& por<=0.63
porindex3 = find(por>0.63);
Sw1 =Sw(porindex1);
Sw2 = Sw(porindex2);
Sw3 = Sw(porindex3);
Sg1 =Sg(porindex1);
Sg2 = Sg(porindex2);
Sg3 = Sg(porindex3);
k_fl1 = ((k_water./Sw1) -k_co2).*(1 - Sg1).^(1.2) + k_co2;
k_fl2 = ((k_water./Sw2) -k_co2).*(1 - Sg2).^(1.6) + k_co2;
k_fl3 = ((k_water./Sw3) -k_co2).*(1 - Sg3).^(2) + k_co2;
I want to merge the values of k_fl1,k_fl2, and k_fl3 values into a single array as k_fl via index position, which is defined by porindex1,porindex2, and porindex3.

Réponse acceptée

Voss
Voss le 28 Août 2023

Use logical indexing:

porindex1 = por<=0.47; %% por<=0.5
porindex2 = por>0.47&por<=0.63; %% por>0.47& por<=0.63
porindex3 = por>0.63;
exponent = zeros(size(por));
exponent(porindex1) = 1.2;
exponent(porindex2) = 1.6;
exponent(porindex3) = 2;
k_fl = (k_water./Sw - k_co2).*(1 - Sg).^exponent + k_co2;
  2 commentaires
Arvind
Arvind le 28 Août 2023
Thank you
Voss
Voss le 28 Août 2023
You're welcome!

Connectez-vous pour commenter.

Plus de réponses (0)

Catégories

En savoir plus sur Simulink dans Help Center et File Exchange

Produits


Version

R2023a

Community Treasure Hunt

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

Start Hunting!

Translated by