I'm getting the error "Array indices must be positive integers or logical values." and it seems like I structures the for loop to handle the equations. Can anyone help me with this?
Show older comments
ds=zeros(length(y),1);
dAs=zeros(length(y),1);
Ac=zeros(length(y),1);
for j=1:N
t1=(t(y(j))+t(y(j+1/2)))/2; %average thickness of CV on side closer to y=0
t2=(t(y(j-1/2))+t(y(j)))/2; %avgerage thickness of CV on side closer to y=L
ds(j)=sqrt((t(y(j+1))-t(t(j-1))).^2+(2*dy).^2)/2; %using central difference
dAs(j)= (w+((t1+t2)/L))*ds(j)*dx; %surface area
Ac(j)=(t(y(j)))*dx; %Cross sectional area
end
3 Comments
Matt Gaidica
on 13 Dec 2020
What are you expecting from y(j+1/2), is this possibly an order of operations issue? It's hard to debug without providing t, y, and N.
Matthew Williams
on 13 Dec 2020
Walter Roberson
on 13 Dec 2020
You cannot index at half-integers . You can index a value and divide the result by 2, though.
Accepted Answer
More Answers (0)
Categories
Find more on Quantum Mechanics 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!