Error in storing for loop iterations

1 view (last 30 days)
james keshecki
james keshecki on 7 Mar 2021
Answered: Walter Roberson on 8 Mar 2021
I am trying to store the values of each for loop iteration so I could plot them in respect to time. However, it keeps giving me the error:
Array indices must be positive integers or logical values.
Error in Rheology (line 16)
s_qtz(i) = A_qtz*(str.^n_qtz)*exp(-Ea_qtz/(R*i));
I am not quite sure of what to do to fix this error. I provided my code below.
%stress array
str = [0.1, 1, 10, 100];
%Constants
R = 8.314;
A_qtz = 1.26e-5;
n_qtz = 3;
Ea_qtz = 2.42e5;
%temp array
T = [973.15:100:1373.15];
for i = T
s_qtz(i) = A_qtz*(str.^n_qtz)*exp(-Ea_qtz/(R*i));
end

Answers (2)

Image Analyst
Image Analyst on 8 Mar 2021

Walter Roberson
Walter Roberson on 8 Mar 2021

Categories

Find more on Loops and Conditional Statements in Help Center and File Exchange

Community Treasure Hunt

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

Start Hunting!