Index exceeds the number of array elements (2).
Show older comments
New to mat lab something wrong with line 9. I just corrected the D(n) still don't know whats going wrong.
clear all
temp = [850:0.1:950];
time = [0:004:4];
for n= 1:1000
D(n)=(2.3.*10^(-5)).*exp((-148000)./(8.314.*((temp(n))+273.15)));
end
for x = 1:1:1000
for k = 1:1:1000
InsideErf(k) = 0.002./((D(x)./(time(k)) ;
end
end
Answers (1)
Walter Roberson
on 5 Dec 2021
D=(2.3.*10^(-5)).*exp((-148000)./(8.314.*((temp)+273.15)));
That overwrites all of D in every iteration of the n loop. You should be assigning to D(n) instead of to D alone.
2 Comments
Thomas McKenney
on 5 Dec 2021
Edited: Walter Roberson
on 5 Dec 2021
Walter Roberson
on 5 Dec 2021
clear all
temp = [850:0.1:950];
time = [0:004:4];
for n= 1:1000
D(n)=(2.3.*10^(-5)).*exp((-148000)./(8.314.*((temp(n))+273.15)));
end
for x = 1:1:1000
for k = 1:1:1000
InsideErf(k) = 0.002./((D(x)./(time(k)) ;
% 1 0 12 3 2 3 4 32
end
end
The digits indicate the number of open bracket levels "after" executing the character directly above. So at the end of the line, there are still two ( that do not have a matching )
Categories
Find more on Matrix Indexing 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!