Hello. Could anyone help me? I keep getting "Index exceeds matrix dimensions."

1 vue (au cours des 30 derniers jours)
arif abdullah
arif abdullah le 22 Mai 2018
Commenté : per isakson le 22 Mai 2018
Error in data_inductor23 (line 70)
max_ipc = max_ipc + (tw_max - DM(i+1,3))*Tool_Power(b(j))*0.1;
.
tw_max = 40; %tw_max = time window max
Tool_Power=[100;120;1500;2800];
n=length(DM(:,1));
min_dc = length(unique(DM(:,1))) - 1;
max_dc = n - 1;
min_tc = length(nonzeros(unique(DM(:,3:end)))) - 1;
max_tc = 0;
for i = 1:n-1
a=length(nonzeros(DM(i,3:end)));
b=length(nonzeros(DM(i+1,3:end)));
max_tc = max_tc + (a.*b);
end
max_ipc = 0;
for i = 1:n
a=length(nonzeros(DM(i,3:end)));
b=nonzeros(DM(i,3:end));
for j = 1:a
max_ipc = max_ipc + (tw_max - DM(i+1,3))*Tool_Power(b(j))*0.1;
end
end
max_ip = max_ipc/3600;
  4 commentaires
arif abdullah
arif abdullah le 22 Mai 2018
Yes it is. Could I send to you the data ?
arif abdullah
arif abdullah le 22 Mai 2018
Modifié(e) : Walter Roberson le 22 Mai 2018
%DM data matrix:
% Dir Time Col 3-5:Tool
DM = [ 6 39 1 0 0 0 0
6 31 1 0 0 0 0
6 48 2 0 0 0 0
3 89 2 0 0 0 0
3 27 3 0 0 0 0
6 48 3 0 0 0 0
6 73 3 0 0 0 0
2 21 2 0 0 0 0
3 64 2 0 0 0 0
2 12 4 0 0 0 0
6 15 4 0 0 0 0
4 65 5 0 0 0 0
4 58 6 0 0 0 0
4 60 7 8 0 0 0
1 45 7 8 0 0 0
1 32 9 0 0 0 0
3 27 10 0 0 0 0
6 70 11 0 0 0 0
6 22 12 0 0 0 0
2 44 1 13 0 0 0
2 19 14 0 0 0 0
6 20 14 0 0 0 0
6 34 0 0 0 0 0];

Connectez-vous pour commenter.

Réponses (1)

Walter Roberson
Walter Roberson le 22 Mai 2018
Your DM has non-zero values as large as 14 in columns 3 to end. Those become your b values. You use b(j) to index Tool_Power, but Tool_Power is only length 4.
  1 commentaire
per isakson
per isakson le 22 Mai 2018
Matlab R2016a says:
Index exceeds matrix dimensions.
Error in cssm (line 45)
max_ipc = max_ipc + (tw_max - DM(i+1,3))*Tool_Power(b(j))*0.1;
Why isn't Matlab more helpful and tells the user which variable and which values of which indicies are involved?

Connectez-vous pour commenter.

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Tags

Community Treasure Hunt

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

Start Hunting!

Translated by