Info
This question is closed. Reopen it to edit or answer.
I keep getting this error, Array indices must be positive integers or logical values. Error in Problem_4 (line 11) for k=2:length(t)
1 view (last 30 days)
Show older comments
density=8495;
diameter=.015;
length=.045;
Cp=4208;
Ts=20;
clc
table=xlsread('RDData.xlsx','palm oil','A1:B609');
t=table(:,1);
T=table(:,2);
A=[t,T];
for k=2:length(t)
delt=(t(k-1)-t(k))
%for L=2:length(T)
%delT=(T(L-1)-T(L));
% end
end
%b=[delt,delT]
(This is my code can anyone tell me why this isnt running?)
0 Comments
Answers (1)
Image Analyst
on 22 Feb 2020
Edited: Image Analyst
on 22 Feb 2020
See The FAQ
By the way, you forgot ot attach 'RDData.xlsx' so we can't run your code.
And you forgot to attach the entire error message -- ALL the red text including the line of text that threw the error.
Also, never use a built-in function/keyword, like "table" for the name of your variable.
1 Comment
Steven Lord
on 22 Feb 2020
While your last example is absolutely valid, in this situation using the name of the built-in length function as a variable name is a bigger problem than using the name table, as it doesn't look like this code tries to call table but does try to call length.
See Also
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!