i want to use a function to calculate values using 2 changing inputs
1 回表示 (過去 30 日間)
古いコメントを表示
clc
clear
M_inf=[1.46772
1.49692
1.52613
1.55533
1.58332
1.61132
1.63931
1.66731
1.69559
1.72386
1.75213
1.78041
1.8086
1.83678
1.86497
1.89316
1.91976
1.94637
1.97297
1.99957
2.0234
2.04722
2.07105
2.09487
2.11495
2.13502
2.15509
2.17517
2.19142
2.20766
2.22391
2.24016
2.25205
2.26394
2.27582
2.28771
2.29508
2.30244
2.30981
2.31717
2.32096
2.32474
2.32853
2.33232
2.33361
2.33491
2.33621
2.3375
2.33593
2.33437
2.3328
2.33123
2.32896
2.32668
2.3244
2.32213
2.31841
2.31469
2.31097
2.30725
2.30266
2.29808
2.29349
2.28891
2.28255
2.27619
2.26984
2.26348
2.25852
2.25356
2.24859
2.24363
2.23861
2.23358
2.22856
2.22354
2.21817
2.2128
2.20743
2.20206
2.19698
2.1919
2.18682
2.18174
2.17738
2.17302
2.16866
2.1643
2.16047
2.15664
2.1528
2.14897
2.14455
2.14012
2.13569
2.13127
2.12759
2.12392
2.12025
2.11657
2.11335
2.11014
2.10692
2.1037
2.09994
2.09618
2.09243
2.08867
2.08502
2.08136
2.0777
2.07405
2.06982
2.06559
2.06136
2.05714
2.05326
2.04939
2.04551
2.04164
2.03812
2.0346
2.03108
2.02756
2.02416
2.02076
2.01736
2.01397
2.01128
2.0086
2.00591
2.00323
1.99994
1.99665
1.99336
1.99008
1.98713
1.98419
1.98124
1.9783
1.97533
1.97236
1.96939
1.96643
1.96315
1.95987
1.95659
1.95331
1.95024
1.94717
1.9441
1.94103
1.93747
1.93392
1.93037
1.92681
1.92399
1.92117
1.91834
1.91552
1.91279
1.91006
1.90733
1.9046
1.90194
1.89927
1.8966
1.89394
1.89146
1.88898
1.8865
1.88401
1.88145
1.87889
1.87632
1.87376
1.87072
1.86769
1.86465
1.86161
1.85882
1.85603
1.85324
1.85045
1.84761
1.84477
1.84194
1.8391
1.83603
1.83297
1.8299
1.82684
1.82439
1.82193
1.81948
1.81703
1.81448
1.81194
1.80939
1.80684
1.80421
1.80157
1.79894
1.7963
1.79397
1.79164
1.78931
1.78698
1.78436
1.78174
1.77912
1.7765
1.77369
1.77088
1.76807
1.76527
1.76298
1.7607
1.75841
1.75613
1.75412
1.75211
1.7501
1.7481
1.74681
1.74552
1.74423
1.74294
1.76277
1.78261
1.80244
1.82227
1.84224
1.86221
1.88218
1.90215
1.92196
1.94177
1.96158
1.98139
2.00088
2.02037
2.03986
2.05935
2.07899
2.09862
2.11826
2.13789
2.15832
2.17875
2.19918
2.21961
2.24088
2.26215
2.28342
2.30469
2.32657
2.34845
2.37033
2.3922
2.4151
2.43799
2.46088
2.48378
2.50714
2.53051
2.55387
2.57724
2.6002
2.62316
2.64611
2.66907
2.69242
2.71576
2.73911
2.76245
2.78471
2.80696];
theta_s=linspace(1,89)
gamma=1.4;
theta_c=zeros(1,length(M_inf))
for i=1:length(M_inf)
for j=1:length(theta_s)
[theta_c(i),M_c]=solvecone(theta_s(j),M_inf(i),gamma)
end
end
im using a function to calculate these values
my goal is to calculate values for each M_inf, for all values of theta_s
ie) let M_inf=1.46772 then let theta_s =linspace(1,89)
then let M_inf= next values and let theta_s =linspace(1,89)
and repeat
how would this be set up?
0 件のコメント
回答 (1 件)
Voss
2022 年 12 月 10 日
M_inf = [ ...
1.46772
1.49692
1.52613
% ...
];
theta_s = linspace(1,89);
gamma = 1.4;
NM = numel(M_inf);
Nth = numel(theta_s);
theta_c = zeros(NM,Nth);
M_c = zeros(NM,Nth);
for i = 1:NM
for j = 1:Nth
[theta_c(i,j),M_c(i,j)] = solvecone(theta_s(j),M_inf(i),gamma);
end
end
0 件のコメント
参考
カテゴリ
Help Center および File Exchange で Matrix Indexing についてさらに検索
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!