for loop to create array
조회 수: 4 (최근 30일)
이전 댓글 표시
I am trying to create three arrays of concentration. Each array uses some of the same constants, however different calues for Kd and Ji.
The only variable changing in the equation to create a array is time (1 to 300 years).
Any help would be great:
%Given through all
JN = (60 * 10^15)/ 2.12;
Co = 415;
e = 2.71828182845;
V = 4 *10^21;
%Ji and Kd for each part 1,2,3
%1
Ji1=(9.1*10^15)/2.12;
KD1 = (2.5 * 10^-2);
%2
Ji2=(9.1*10^15)/2.12;
KD2 = (1.8 * 10^-2);
%3
Ji3=(14*10^15)/2.12;
KD3 = (2 * 10^-2);
%create arrays
t=1:300;
C1=[];
C2=[];
C3=[];
%Calculation of each part using equation given
for i = 1:300
C1= ((JN + Ji1)/(KD1 * V))+(Co - ((JN + Ji1)/(KD1 * V)))*e^(-KD1*t(i));
end
for i = 1:300
C2= ((JN + Ji2)/(KD2 * V))+(Co - ((JN + Ji2)/(KD2 * V)))*e^(-KD2*t(i));
end
for i = 1:300
C3= ((JN + Ji3)/(KD3 * V))+(Co - ((JN + Ji3)/(KD3 * V)))*e^(-KD3 * t(i));
end
댓글 수: 0
답변 (1개)
Walter Roberson
2020년 12월 7일
No loops
C1= ((JN + Ji1)/(KD1 * V))+(Co - ((JN + Ji1)/(KD1 * V)))*exp(-KD1*t);
Notice exp() and notice t is not subscripted
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!