【问题标题】:How to test different values within an array如何测试数组中的不同值
【发布时间】:2022-01-01 14:18:49
【问题描述】:

我正在尝试在 matlab 中编写一个代码,该代码总共运行 6 次,每次运行测试方程中的 10 个不同值。所以它应该插入一个 mumax = 0.48、Ksphe = 25、Ksglu = 50、Ksser = 175 和 Ksthr = 100,然后在它们的范围内测试 10 个不同的 Sphe、Sglu、Sser 和 Sthr 值。然后它应该移动到下一个 Ks 值并测试 10 个不同的 S 值。

我对如何做到这一点有点迷茫。任何帮助深表感谢。谢谢!

代码:

mumax = [0.48 0.47 0.51 0.49 0.49 0.43];
Sphe = linspace(40,60,10);
Sglu = linspace(85,115,10);
Sser = linspace(350,400,10);
Sthr = linspace(180,220,10);
Ksphe = [25 20 17 18 27 40];
Ksglu = [50 47 56 51 40 30];
Ksser = [175 150 200 22 175 120];
Ksthr = [100 80 120 90 110 100];

mu = mumax .* (Sphe./(Sphe+Ksphe)) .* (Sglu./(Sglu+Ksglu)) .* (Sser./(Sser+Ksser)) .* (Sthr./(Sthr+Ksthr))

【问题讨论】:

    标签: arrays matlab loops


    【解决方案1】:
    clc; clear; close all;
    mumax = [0.48 0.47 0.51 0.49 0.49 0.43];
    Sphe = linspace(40,60,10);
    Sglu = linspace(85,115,10);
    Sser = linspace(350,400,10);
    Sthr = linspace(180,220,10);
    Ksphe = [25 20 17 18 27 40]; 
    Ksglu = [50 47 56 51 40 30];
    Ksser = [175 150 200 22 175 120];  
    Ksthr = [100 80 120 90 110 100]; 
    % We create a meshgrid of the two type of arrays
    % The mumax group will increase in the x direction and the Sphe group in the y 
    % direction
    [mumaxGrid,SpheGrid]=meshgrid(mumax,Sphe);
    [KspheGrid,SgluGrid]=meshgrid(Ksphe,Sglu);
    [KsgluGrid,SserGrid]=meshgrid(Ksglu,Sser);
    [KsserGrid,SthrGrid]=meshgrid(Ksser,Sthr);
    [KsthrGrid,SthrGrid]=meshgrid(Ksthr,Sthr);    
    
    mu = mumaxGrid .* (SpheGrid./(SpheGrid+KspheGrid)) .* (SgluGrid./(SgluGrid+KsgluGrid)) .*...
    (SserGrid./(SserGrid+KsserGrid)) .* (SthrGrid./(SthrGrid+KsthrGrid));
    % mu is a 10 x 6 matrix. 
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-04-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-01-05
      相关资源
      最近更新 更多