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?
1 Ansicht (letzte 30 Tage)
Ältere Kommentare anzeigen
Matthew Williams
am 13 Dez. 2020
Beantwortet: Gouri Chennuru
am 16 Dez. 2020
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 Kommentare
Walter Roberson
am 13 Dez. 2020
You cannot index at half-integers . You can index a value and divide the result by 2, though.
Akzeptierte Antwort
Gouri Chennuru
am 16 Dez. 2020
Hi Matthew,
As per my understanding, you are trying to extract the variable "y" with indices (j+1/2) and (j-1/2), from the following lines.
t1=(t(y(j))+t(y(j+1/2)))/2;
t2=(t(y(j-1/2))+t(y(j)))/2;
You cannot point arrays to a particular decimal index.As a workaround make sure that array Index is always a positive integer or a logical value.
Regards,
Gouri Chennuru
0 Kommentare
Weitere Antworten (0)
Siehe auch
Kategorien
Mehr zu Matrices and Arrays finden Sie in Help Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!