how to do if and else statement for this equation

Hi,
I ma trying to do if and else stituation for my code. I dont what is the proble. I should get my answer as Wsim= [10X5]. can please somebody help? it is important. I will be extremely grateful.
q=[
0.000585366
0.015219512
0.100829268
0.153512195
0.211317073
];
c1=[2.913953437
0.357062085
15.85599407
2.345265863
0.46210313
8.900276197
0.916228389
0.464613769
0.50948815
3.625787133
];
c2=[0.381190238
2.378275189
0.145437759
0.373540574
2.071089271
0.197531521
0.777306452
1.590828583
1.401326121
0.381022168
];
c3=[1.357856932
1.393019098
1.239392127
1.740872069
1.921689678
1.041252003
0.974309699
0.516968399
1.098337754
0.636148757
];
c4=[1.634449245
1.455924213
1.172657972
1.114923556
0.459329589
0.263155864
1.640481459
0.547592137
1.999694643
0.589185378
];
ADP=2.37;
time= [0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
];
N = length(q);
QsL = zeros(N,1);
msL = zeros(N,1);
for t=1:N
if t==1
Bini = c1*(1-exp(-ADP*c2))*24.6*10^6;
QsL(t) =c3*q(t)^c4*Bini;
msL(t)=QsL(t)*time(t);
else
Bini=Bini-msL(t-1);
QsL(t) =c3*q(t)^c4*Bini;
msL(t)=QsL(t)*time(t);
end
end
W_sim=QsL;

 Accepted Answer

q=[
0.000585366
0.015219512
0.100829268
0.153512195
0.211317073
];
c1=[2.913953437
0.357062085
15.85599407
2.345265863
0.46210313
8.900276197
0.916228389
0.464613769
0.50948815
3.625787133
];
c2=[0.381190238
2.378275189
0.145437759
0.373540574
2.071089271
0.197531521
0.777306452
1.590828583
1.401326121
0.381022168
];
c3=[1.357856932
1.393019098
1.239392127
1.740872069
1.921689678
1.041252003
0.974309699
0.516968399
1.098337754
0.636148757
];
c4=[1.634449245
1.455924213
1.172657972
1.114923556
0.459329589
0.263155864
1.640481459
0.547592137
1.999694643
0.589185378
];
ADP=2.37;
time= [0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
];
N = length(q);
M = length(c1);
QsL = zeros(M,N);
msL = zeros(M,N);
for t=1:N
if t==1
Bini = c1.*(1-exp(-ADP*c2))*24.6*10^6;
QsL(:,t) =c3.*q(t).^c4.*Bini;
msL(:,t)=QsL(t)*time(t);
else
Bini=Bini-msL(:,t-1);
QsL(:,t) =c3.*q(t).^c4.*Bini;
msL(:,t)=QsL(:,t)*time(t);
end
end
W_sim=QsL
W_sim = 10×5
1.0e+07 * 0.0000 0.0062 0.1362 0.2705 0.4556 0.0000 0.0028 0.0432 0.0796 0.1265 0.0023 0.1041 0.9562 1.5632 2.2687 0.0015 0.0555 0.4569 0.7284 1.0364 0.0710 0.3171 0.7523 0.9024 1.0309 1.2020 2.8331 4.6329 5.1257 5.5164 0.0000 0.0019 0.0429 0.0854 0.1441 0.0098 0.0584 0.1642 0.2062 0.2449 0.0000 0.0003 0.0135 0.0313 0.0592 0.0420 0.2866 0.8724 1.1145 1.3406

8 Comments

Thank you so much. It means a lot. Can you I ask how can I plot 5 and 95% confidence interval for this data. It would be great help!.
Hi,
I have tried your code but my answer should come differently. I dont know where it is going wrong. can you please help me in this.
Th answer should start at 36 and 37 column as 1791128.29017728 15331651.4669355
181094976.247917 564320758.908682
q=[0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.000585366
0.015219512
0.100829268
0.153512195
0.211317073
0.272780488
0.335121951
0.47795122
0.619317073
0.70404878
0.838829268
0.95604878
1.028926829
1.102097561
1.133414634
1.186536585
1.175853659
1.180390244
1.153609756
1.210390244
1.199121951
1.186390244
1.214780488
1.164
1.154195122
1.162829268
1.150390244
1.160780488
1.193414634
1.192829268
1.192536585
1.191512195
1.268195122
1.319268293
1.345609756
1.344731707
1.390536585
1.436341463
1.481853659
1.531463415
1.421268293
1.364634146
1.362146341
1.303463415
1.283707317
1.191073171
1.208341463
1.117317073
1.041365854
1.026585366
1.022926829
0.949902439
0.922243902
0.904829268
0.852585366
0.832390244
0.83195122
0.78995122
0.793756098
0.769463415
0.759219512
0.73404878
0.704195122
0.735804878
0.714146341
0.718390244
0.646829268
0.675512195
0.646390244
0.628097561
0.642146341
0.612
0.571317073
0.54497561
0.51702439
0.498585366
0.450731707
0.443268293
0.41604878
0.380195122
0.374341463
0.346097561
0.322390244
0.306146341
0.272780488
0.260487805
0.236487805
0.220390244
0.211317073
0.196536585
0.186439024
0.176634146
0.163317073
0.151756098
0.143121951
0.12995122
0.12204878
0.115463415
0.108878049
0.103170732
0.096439024
0.091463415
0.086634146
0.078146341
0.075804878
0.07404878
0.067317073
0.034243902
0.03204878
0.022243902
0.020926829
0.019902439
0.01902439
0.018
0.007317073
0.009219512
0.007170732
0.006731707
0.004097561
0.004243902
0.004097561
0.004682927
0.004536585
0.004243902
0.004097561
0.00395122
0.004682927
0.004390244
0.004243902
0.004682927
0.004536585
0.004390244
0.003365854
0.004243902
0.004097561
0.002634146
0.002634146
0.002487805
0.002341463
0.002341463
0.002195122
0.00204878
0.00204878
0.001902439
0.001902439
0.001756098
0.001756098
0.001756098
0.001756098
0.001756098
0.001609756
0.001609756
0.001609756
0.001463415
0.001463415
0.001463415
0.001463415
0.001317073
0.001317073
0.001317073
0.001317073
0.001317073
0.001317073
0.001170732
0.001170732
0.001170732
0.001170732
0.001170732
0.001170732
0.001170732
0.00102439
0.00102439
0.00102439
0.00102439
0.00102439
0.000878049
0.000878049
0.000878049
0.000878049
0.000878049
0.000878049
0.000878049
0.000878049
0.000878049
0.000731707
0.000878049
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000585366
0.000585366
0.000585366
0.000585366
0.000585366
0.000585366
0.000585366
0.000585366
0.000585366];
c1=[9.96758922769766
21.7863553786390];
c2=[1.07087547298308
4.59298875702875];
c3=[0.659036959801163
0.350587816233283];
c4=[1.35390855987385
0.572921003882392];
ADP=2.37;
time= [0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667];
N = length(q);
M = length(c1);
QsL = zeros(M,N);
msL = zeros(M,N);
for t=1:N
if t==1
Bini = c1.*(1-exp(-ADP.*c2)).*24.6.*10^6;
QsL(:,t) =c3.*(q(t).^c4).*Bini;
msL(:,t)=QsL(t).*time(t);
else
Bini=Bini-msL(:,t-1);
QsL(:,t) =c3.*(q(t).^c4).*Bini;
msL(:,t)=QsL(:,t).*time(t);
end
end
W_sim=QsL;
for i=1:24
W_sim(:,10*(i-1)+1:10*i)
end
ans = 2×10
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ans = 2×10
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ans = 2×10
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ans = 2×10
1.0e+07 * 0 0 0 0 0 0.0006 0.0515 0.6662 1.1764 1.8117 0 0 0 0 0 0.2642 1.7082 5.0440 6.4074 7.6795
ans = 2×10
1.0e+08 * 0.2556 0.3372 0.5439 0.7693 0.9099 1.1455 1.3556 1.4819 1.6078 1.6490 0.8868 0.9950 1.2156 1.4048 1.5051 1.6561 1.7755 1.8413 1.9038 1.9227
ans = 2×10
1.0e+08 * 1.7317 1.6870 1.6726 1.5991 1.6839 1.6390 1.5928 1.6219 1.5089 1.4716 1.9614 1.9387 1.9305 1.8931 1.9336 1.9107 1.8867 1.9001 1.8421 1.8215
ans = 2×10
1.0e+08 * 1.4667 1.4260 1.4243 1.4589 1.4376 1.4171 1.3957 1.4975 1.5558 1.5725 1.8177 1.7950 1.7929 1.8100 1.7978 1.7859 1.7735 1.8261 1.8554 1.8637
ans = 2×10
1.0e+08 * 1.5453 1.5905 1.6333 1.6732 1.7167 1.5213 1.4144 1.3873 1.2852 1.2391 1.8501 1.8729 1.8945 1.9148 1.9370 1.8420 1.7867 1.7724 1.7162 1.6897
ans = 2×10
1.0e+08 * 1.1023 1.1084 0.9827 0.8820 0.8550 0.8412 0.7523 0.7154 0.6903 0.6308 1.6078 1.6106 1.5299 1.4603 1.4397 1.4283 1.3608 1.3304 1.3086 1.2578
ans = 2×10
1.0e+08 * 0.6053 0.5997 0.5543 0.5534 0.5263 0.5129 0.4863 0.4564 0.4810 0.4586 1.2340 1.2272 1.1850 1.1822 1.1554 1.1408 1.1134 1.0819 1.1041 1.0801
ans = 2×10
1.0e+08 * 0.4591 0.3955 0.4169 0.3902 0.3730 0.3821 0.3559 0.3224 0.3009 0.2788 1.0785 1.0107 1.0314 1.0010 0.9802 0.9883 0.9571 0.9160 0.8878 0.8579
ans = 2×10
1.0e+07 * 2.6427 2.2953 2.2357 2.0443 1.8035 1.7607 1.5787 1.4304 1.3305 1.1355 8.3683 7.8672 7.7635 7.4592 7.0588 6.9729 6.6442 6.3593 6.1548 5.7440
ans = 2×10
1.0e+07 * 1.0648 0.9325 0.8463 0.7983 0.7227 0.6721 0.6240 0.5606 0.5070 0.4680 5.5787 5.2639 5.0426 4.9105 4.6994 4.5490 4.4005 4.1981 4.0169 3.8766
ans = 2×10
1.0e+07 * 0.4103 0.3766 0.3492 0.3223 0.2995 0.2732 0.2542 0.2361 0.2052 0.1969 3.6610 3.5253 3.4091 3.2907 3.1855 3.0598 2.9638 2.8689 2.7004 2.6501
ans = 2×10
1.0e+07 * 0.1907 0.1675 0.0671 0.0613 0.0374 0.0344 0.0322 0.0303 0.0281 0.0083 2.6113 2.4693 1.6744 1.6107 1.3055 1.2598 1.2233 1.1914 1.1535 0.6883
ans = 2×10
1.0e+06 * 0.1134 0.0807 0.0741 0.0378 0.0397 0.0378 0.0453 0.0434 0.0397 0.0378 7.8549 6.7989 6.5549 4.9306 5.0295 4.9281 5.3186 5.2213 5.0242 4.9230
ans = 2×10
1.0e+06 * 0.0360 0.0453 0.0415 0.0397 0.0453 0.0434 0.0415 0.0290 0.0397 0.0378 4.8202 5.3117 5.1175 5.0178 5.3076 5.2105 5.1122 4.3891 5.0114 4.9104
ans = 2×10
1.0e+06 * 0.0208 0.0208 0.0193 0.0177 0.0177 0.0162 0.0148 0.0148 0.0134 0.0134 3.8113 3.8105 3.6871 3.5605 3.5599 3.4300 3.2965 3.2960 3.1584 3.1579
ans = 2×10
1.0e+06 * 0.0120 0.0120 0.0120 0.0120 0.0120 0.0107 0.0107 0.0107 0.0094 0.0094 3.0159 3.0154 3.0150 3.0145 3.0140 2.8670 2.8666 2.8662 2.7135 2.7131
ans = 2×10
1.0e+06 * 0.0094 0.0094 0.0081 0.0081 0.0081 0.0081 0.0081 0.0081 0.0069 0.0069 2.7127 2.7123 2.5531 2.5528 2.5524 2.5521 2.5518 2.5514 2.3846 2.3843
ans = 2×10
1.0e+06 * 0.0069 0.0069 0.0069 0.0069 0.0069 0.0058 0.0058 0.0058 0.0058 0.0058 2.3840 2.3838 2.3835 2.3832 2.3829 2.2071 2.2069 2.2066 2.2064 2.2061
ans = 2×10
1.0e+06 * 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0037 2.0194 2.0192 2.0190 2.0188 2.0186 2.0184 2.0181 2.0179 2.0177 1.8174
ans = 2×10
1.0e+06 * 0.0047 0.0037 0.0037 0.0037 0.0037 0.0037 0.0037 0.0037 0.0037 0.0037 2.0173 1.8171 1.8169 1.8167 1.8165 1.8164 1.8162 1.8160 1.8159 1.8157
ans = 2×10
1.0e+06 * 0.0037 0.0037 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 1.8155 1.8154 1.5973 1.5972 1.5971 1.5970 1.5968 1.5967 1.5966 1.5964
I dont know where it is going wrong.
How should I ? I just corrected some technical MATLAB errors. I can't tell whether your t-loop and your data are correct.
I think I need Bin of same matrix as QSL and MSL. The formula remain the same . Please if you could help me with this. Thank you so much for the comment.
when T=1, the formula should be this
if t==1
Bini = c1.*(1-exp(-ADP.*c2)).*24.6.*10^6;
QsL(:,t) =c3.*(q(t).^c4).*Bini;
msL(:,t)=QsL(t).*time(t);
and timestep t =2:N,then formual should be this
else
Bini=Bini-msL(:,t-1);
QsL(:,t) =c3.*(q(t).^c4).*Bini;
msL(:,t)=QsL(:,t).*time(t);
end
for all the q and c1 ,c2,c3,c4 combination so,Bin matrix should be (M,N) same as QSL and MSL.
when T=1, the formula should be this
if t==1
Bini = c1.*(1-exp(-ADP.*c2)).*24.6.*10^6;
QsL(:,t) =c3.*(q(t).^c4).*Bini;
msL(:,t)=QsL(t).*time(t);
and timestep t =2:N,then formual should be this
else
Bini=Bini-msL(:,t-1);
QsL(:,t) =c3.*(q(t).^c4).*Bini;
msL(:,t)=QsL(:,t).*time(t);
end
I don't see any difference to your already existing code.
can you please help me to get the code where Bin has alssame matrix as qsl and msl. When I run the code with dataset , I have found that BIn matrix is diffreent from qsl and Msl . that is why my amswer are coing wrong.
How can I make change in the above code so that BIN as same matrix as QSL and MSL with this time loop. I wanted Bin =Zeros (M,N).
Please can you help me in this.
can you please help me to get the code where Bin has alssame matrix as qsl and msl.
You can do this, but it won't change the result:
q=[0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0
0.000585366
0.015219512
0.100829268
0.153512195
0.211317073
0.272780488
0.335121951
0.47795122
0.619317073
0.70404878
0.838829268
0.95604878
1.028926829
1.102097561
1.133414634
1.186536585
1.175853659
1.180390244
1.153609756
1.210390244
1.199121951
1.186390244
1.214780488
1.164
1.154195122
1.162829268
1.150390244
1.160780488
1.193414634
1.192829268
1.192536585
1.191512195
1.268195122
1.319268293
1.345609756
1.344731707
1.390536585
1.436341463
1.481853659
1.531463415
1.421268293
1.364634146
1.362146341
1.303463415
1.283707317
1.191073171
1.208341463
1.117317073
1.041365854
1.026585366
1.022926829
0.949902439
0.922243902
0.904829268
0.852585366
0.832390244
0.83195122
0.78995122
0.793756098
0.769463415
0.759219512
0.73404878
0.704195122
0.735804878
0.714146341
0.718390244
0.646829268
0.675512195
0.646390244
0.628097561
0.642146341
0.612
0.571317073
0.54497561
0.51702439
0.498585366
0.450731707
0.443268293
0.41604878
0.380195122
0.374341463
0.346097561
0.322390244
0.306146341
0.272780488
0.260487805
0.236487805
0.220390244
0.211317073
0.196536585
0.186439024
0.176634146
0.163317073
0.151756098
0.143121951
0.12995122
0.12204878
0.115463415
0.108878049
0.103170732
0.096439024
0.091463415
0.086634146
0.078146341
0.075804878
0.07404878
0.067317073
0.034243902
0.03204878
0.022243902
0.020926829
0.019902439
0.01902439
0.018
0.007317073
0.009219512
0.007170732
0.006731707
0.004097561
0.004243902
0.004097561
0.004682927
0.004536585
0.004243902
0.004097561
0.00395122
0.004682927
0.004390244
0.004243902
0.004682927
0.004536585
0.004390244
0.003365854
0.004243902
0.004097561
0.002634146
0.002634146
0.002487805
0.002341463
0.002341463
0.002195122
0.00204878
0.00204878
0.001902439
0.001902439
0.001756098
0.001756098
0.001756098
0.001756098
0.001756098
0.001609756
0.001609756
0.001609756
0.001463415
0.001463415
0.001463415
0.001463415
0.001317073
0.001317073
0.001317073
0.001317073
0.001317073
0.001317073
0.001170732
0.001170732
0.001170732
0.001170732
0.001170732
0.001170732
0.001170732
0.00102439
0.00102439
0.00102439
0.00102439
0.00102439
0.000878049
0.000878049
0.000878049
0.000878049
0.000878049
0.000878049
0.000878049
0.000878049
0.000878049
0.000731707
0.000878049
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000731707
0.000585366
0.000585366
0.000585366
0.000585366
0.000585366
0.000585366
0.000585366
0.000585366
0.000585366];
c1=[9.96758922769766
21.7863553786390];
c2=[1.07087547298308
4.59298875702875];
c3=[0.659036959801163
0.350587816233283];
c4=[1.35390855987385
0.572921003882392];
ADP=2.37;
time= [0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667
0.016666667];
N = length(q);
M = length(c1);
QsL = zeros(M,N);
msL = zeros(M,N);
Bini =zeros(M,N);
for t=1:N
if t==1
Bini(:,t) = c1.*(1-exp(-ADP.*c2)).*24.6.*10^6;
QsL(:,t) =c3.*(q(t).^c4).*Bini(:,t);
msL(:,t)=QsL(:,t).*time(t);
else
Bini(:,t)=Bini(:,t-1)-msL(:,t-1);
QsL(:,t) =c3.*(q(t).^c4).*Bini(:,t);
msL(:,t)=QsL(:,t).*time(t);
end
end
W_sim=QsL;
for i=1:24
W_sim(:,10*(i-1)+1:10*i)
end
ans = 2×10
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ans = 2×10
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ans = 2×10
0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
ans = 2×10
1.0e+07 * 0 0 0 0 0 0.0006 0.0515 0.6662 1.1764 1.8117 0 0 0 0 0 0.2642 1.7082 5.0440 6.4074 7.6795
ans = 2×10
1.0e+08 * 0.2556 0.3372 0.5439 0.7693 0.9099 1.1455 1.3556 1.4819 1.6078 1.6490 0.8868 0.9950 1.2156 1.4048 1.5051 1.6561 1.7755 1.8413 1.9038 1.9227
ans = 2×10
1.0e+08 * 1.7317 1.6870 1.6726 1.5991 1.6839 1.6390 1.5928 1.6219 1.5089 1.4716 1.9614 1.9387 1.9305 1.8931 1.9336 1.9107 1.8867 1.9001 1.8421 1.8215
ans = 2×10
1.0e+08 * 1.4667 1.4260 1.4243 1.4589 1.4376 1.4171 1.3957 1.4975 1.5558 1.5725 1.8177 1.7950 1.7929 1.8100 1.7978 1.7859 1.7735 1.8261 1.8554 1.8637
ans = 2×10
1.0e+08 * 1.5453 1.5905 1.6333 1.6732 1.7167 1.5213 1.4144 1.3873 1.2852 1.2391 1.8501 1.8729 1.8945 1.9148 1.9370 1.8420 1.7867 1.7724 1.7162 1.6897
ans = 2×10
1.0e+08 * 1.1023 1.1084 0.9827 0.8820 0.8550 0.8412 0.7523 0.7154 0.6903 0.6308 1.6078 1.6106 1.5299 1.4603 1.4397 1.4283 1.3608 1.3304 1.3086 1.2578
ans = 2×10
1.0e+08 * 0.6053 0.5997 0.5543 0.5534 0.5263 0.5129 0.4863 0.4564 0.4810 0.4586 1.2340 1.2272 1.1850 1.1822 1.1554 1.1408 1.1134 1.0819 1.1041 1.0801
ans = 2×10
1.0e+08 * 0.4591 0.3955 0.4169 0.3902 0.3730 0.3821 0.3559 0.3224 0.3009 0.2788 1.0785 1.0107 1.0314 1.0010 0.9802 0.9883 0.9571 0.9160 0.8878 0.8579
ans = 2×10
1.0e+07 * 2.6427 2.2953 2.2357 2.0443 1.8035 1.7607 1.5787 1.4304 1.3305 1.1355 8.3683 7.8672 7.7635 7.4592 7.0588 6.9729 6.6442 6.3593 6.1548 5.7440
ans = 2×10
1.0e+07 * 1.0648 0.9325 0.8463 0.7983 0.7227 0.6721 0.6240 0.5606 0.5070 0.4680 5.5787 5.2639 5.0426 4.9105 4.6994 4.5490 4.4005 4.1981 4.0169 3.8766
ans = 2×10
1.0e+07 * 0.4103 0.3766 0.3492 0.3223 0.2995 0.2732 0.2542 0.2361 0.2052 0.1969 3.6610 3.5253 3.4091 3.2907 3.1855 3.0598 2.9638 2.8689 2.7004 2.6501
ans = 2×10
1.0e+07 * 0.1907 0.1675 0.0671 0.0613 0.0374 0.0344 0.0322 0.0303 0.0281 0.0083 2.6113 2.4693 1.6744 1.6107 1.3055 1.2598 1.2233 1.1914 1.1535 0.6883
ans = 2×10
1.0e+06 * 0.1134 0.0807 0.0741 0.0378 0.0397 0.0378 0.0453 0.0434 0.0397 0.0378 7.8549 6.7989 6.5549 4.9306 5.0295 4.9281 5.3186 5.2213 5.0242 4.9230
ans = 2×10
1.0e+06 * 0.0360 0.0453 0.0415 0.0397 0.0453 0.0434 0.0415 0.0290 0.0397 0.0378 4.8202 5.3117 5.1175 5.0178 5.3076 5.2105 5.1122 4.3891 5.0114 4.9104
ans = 2×10
1.0e+06 * 0.0208 0.0208 0.0193 0.0177 0.0177 0.0162 0.0148 0.0148 0.0134 0.0134 3.8113 3.8105 3.6871 3.5605 3.5599 3.4300 3.2965 3.2960 3.1584 3.1579
ans = 2×10
1.0e+06 * 0.0120 0.0120 0.0120 0.0120 0.0120 0.0107 0.0107 0.0107 0.0094 0.0094 3.0159 3.0154 3.0150 3.0145 3.0140 2.8670 2.8666 2.8662 2.7135 2.7131
ans = 2×10
1.0e+06 * 0.0094 0.0094 0.0081 0.0081 0.0081 0.0081 0.0081 0.0081 0.0069 0.0069 2.7127 2.7123 2.5531 2.5528 2.5524 2.5521 2.5518 2.5514 2.3846 2.3843
ans = 2×10
1.0e+06 * 0.0069 0.0069 0.0069 0.0069 0.0069 0.0058 0.0058 0.0058 0.0058 0.0058 2.3840 2.3838 2.3835 2.3832 2.3829 2.2071 2.2069 2.2066 2.2064 2.2061
ans = 2×10
1.0e+06 * 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0047 0.0037 2.0194 2.0192 2.0190 2.0188 2.0186 2.0184 2.0181 2.0179 2.0177 1.8174
ans = 2×10
1.0e+06 * 0.0047 0.0037 0.0037 0.0037 0.0037 0.0037 0.0037 0.0037 0.0037 0.0037 2.0173 1.8171 1.8169 1.8167 1.8165 1.8164 1.8162 1.8160 1.8159 1.8157
ans = 2×10
1.0e+06 * 0.0037 0.0037 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 0.0027 1.8155 1.8154 1.5973 1.5972 1.5971 1.5970 1.5968 1.5967 1.5966 1.5964

Sign in to comment.

More Answers (0)

Categories

Find more on Sparse Matrices in Help Center and File Exchange

Asked:

on 24 Aug 2022

Edited:

on 27 Aug 2022

Community Treasure Hunt

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

Start Hunting!