Index in position 1 exceeds array bounds (must not exceed 1).

2 次查看(过去 30 天)
I am getting an error in the following line.In the matlab live editor this was not shown as an error but dont know why in the .m file I am getting this error.
m=1200;
A_f=2;
rho=1.205;
g=9.8;
r=0.3;
f=0.01;
C=0.3;
delta_1 =0.04;
delta_2=0.017;
i_fd=3.29;
i_1=1;
eff_tr=0.95;
delta=1+(delta_1)+(delta_2)*(i_fd)^2*(i_1)^2;
T_whl(1:1436,1)=((delta.*m).*(a(1:1436,1))+0.5.*C.*A_f.*rho.*v(1:1436,1).^2+m.*g.*f).*r; %ERROR :Index in position 1 exceeds array bounds (must not exceed 1).
% a,v in the equation are vectors from .mat file
w(1:1436,1)=v(1:1436,1)./r
global P_load;
P_load(1:1436,1)=T_whl(1:1436,1).*w(1:1436,1);

回答(1 个)

KSSV
KSSV 2021-7-16
A = rand(1,10) ;
A(1) % no error
A(2) % no error
A(2,1) % error, becuase A is a row matrix
In your case also check are you trying to teat row matrix as a column matrix? This line:
P_load(1:1436,1)=T_whl(1:1436,1).*w(1:1436,1);
Check it, I don't think index 1 is needed.
P_load(1:1436)=T_whl(1:1436).*w(1:1436);
  2 个评论
Laxmi Akshaya Thela
%I am still getting an error.Please have alookat .mat file attached below
%for the data
eff_tr=0.95;
delta=1+(delta_1)+(delta_2)*(i_fd)^2*(i_1)^2;
T_whl(1:1436)=((delta.*m).*(a(1:1436))+0.5.*C.*A_f.*rho.*v(1:1436).^2+m.*g.*f).*r;%Index exceeds the number of array elements (1).
w(1:1436,1)=v(1:1436,1)./r
global P_load;
P_load(1:1436,1)=T_whl(1:1436,1).*w(1:1436,1);
%Thanks in advance
Laxmi Akshaya Thela
I am still getting an error for the above uquestion could someone please help me to figure out the issue

请先登录,再进行评论。

类别

Help CenterFile Exchange 中查找有关 Matrix Indexing 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by