Info

此问题已关闭。 请重新打开它进行编辑或回答。

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 次查看(过去 30 天)
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?)

回答(1 个)

Image Analyst
Image Analyst 2020-2-22
编辑:Image Analyst 2020-2-22
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 个评论
Steven Lord
Steven Lord 2020-2-22
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.

Community Treasure Hunt

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

Start Hunting!

Translated by