??? Matrix index is out of range for deletion...
Mostra commenti meno recenti
[finalLinkCost1DMatrix, path, corelation] = getSetOfPlanes(topology,realCapacityTopology,costTopology,AR,GW,X(x));
path1=path;
finalLinkCost1DMatrix1=finalLinkCost1DMatrix;
for k=1:size(finalLinkCost1DMatrix,3)
for f=1:6
if path(f,8,k)~=0
path1(:,:,k)=[];
finalLinkCost1DMatrix(:,:,k)=[];
break;
else
continue;
end
end
end
I get
??? Matrix index is out of range for deletion.
Error in ==> topo at 76 path1(:,:,k)=[]; Can anyone help me with this. with thanks
2 Commenti
Sara
il 23 Mag 2014
What is the size of path?
Risposta accettata
Più risposte (2)
dpb
il 23 Mag 2014
for k=1:size(finalLinkCost1DMatrix,3)
for f=1:6
if path(f,8,k)~=0
path1(:,:,k)=[];
finalLinkCost1DMatrix(:,:,k)=[];
...
First problem is you've not shown definition for path so can't tell about the subject error line precisely, but presuming it also is commensurate with k, you have implemented a classic "woops" case.
You started from k=1 working to the end of the total number of planes in your working arrays and delete an element, thus shortening the remaining array. In your case the element is a plane, it's common error in processing strings or 1D vectors as well.
You need to either
a) Reverse the processing on k to remove the LAST plane(s) first, or,
b) Make a secondary array of those planes which need removing and after the list is populated, do a global change.
Categorie
Scopri di più su Matrices and Arrays in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!