【问题标题】:The use of all possible combinations使用所有可能的组合
【发布时间】:2011-10-16 22:52:46
【问题描述】:

所以我想弄清楚如何使用,

parameters = {[6 12 18 24], [1200 1800 2400 3000], [80 90 100],[80 90 100],[80 90 100]};

[r T3 Ec Et Er ] = ndgrid(parameters{:});

Allcombinations = [r(:) T3(:) Ec(:) Et(:) Er(:)];

这为我提供了原始参数的所有可能组合

我需要将每个参数组合插入到许多方程中,最好的方法是什么?

例如,如果我想拉出第一行并将相应的值插入例如,例如;

%# Note: k, Cp and T1 are predefined constants

Ec1=Ec/100;

Et1=Et/100;

Er1=Er/100;

T2s=T1*(r)^((k-1)/k);

T4s=T3*(1/r)^((k-1)/k);

T2a=((T2s-T1)/Ec1)+T1;

T4a=T3-Et1*(T3-T4s);

wca=Cp*(T2a-T1);

wta=Cp*(T3-T4a);

T5s=Er1*(T4a-T2a)+T2a;

qcombustion=Cp*(T3-T5s);

qregen=Cp*(T5s-T2a);

qin=qcombustion+qregen;

fprintf ('\n Net Work Output=%6.2f', wnet)

fprintf ('\n Back Work Ratio=%4.2f', rbw)

fprintf ('\n Thermal Efficiency=%4.2f\n', Eth)

我不确定,但我想知道如何使用Allcombinations(n,:)

非常感谢一些帮助 谢谢

【问题讨论】:

    标签: matlab combinatorics


    【解决方案1】:

    您可以使用element-wise operators 一次性计算所有可能组合的所有内容:

    %# Note: k, Cp and T1 are predefined constants
    
    parameters = {[6 12 18 24], [1200 1800 2400 3000], [80 90 100],[80 90 100],[80 90 100]};
    
    [r T3 Ec Et Er ] = ndgrid(parameters{:});
    
    %# turn arrays into vectors
    r = r(:);
    T3 = T3(:);
    Ec1=Ec(:)/100;
    Et1=Et(:)/100;
    Er1=Er(:)/100;
    
    %# perform calculations using element-wise operators
    
    T2s=T1.*(r).^((k-1)/k);
    
    T4s=T3.*(1./r).^((k-1)/k);
    
    T2a=((T2s-T1)./Ec1)+T1;
    
    T4a=T3-Et1.*(T3-T4s);
    
    wca=Cp*(T2a-T1);
    
    wta=Cp*(T3-T4a);
    
    T5s=Er1.*(T4a-T2a)+T2a;
    
    qcombustion=Cp*(T3-T5s);
    
    qregen=Cp*(T5s-T2a);
    
    qin=qcombustion+qregen;
    
    %# Warning: These statements will produce a lot of output!
    
    %# If you want to show the output for, say, combination #5
    %# use e.g. wnet(5)
    
    fprintf ('\n Net Work Output=%6.2f', wnet)
    
    fprintf ('\n Back Work Ratio=%4.2f', rbw)
    
    fprintf ('\n Thermal Efficiency=%4.2f\n', Eth)
    

    【讨论】:

    • 谢谢。关于结果,我知道它应该是一个 426x 5 矩阵,我需要将它们全部绘制出来,非常感谢
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-04-06
    • 1970-01-01
    • 2023-03-22
    • 1970-01-01
    • 2012-03-27
    相关资源
    最近更新 更多