Effacer les filtres
Effacer les filtres

Improper assignment with rectangular empty matrix.

3 vues (au cours des 30 derniers jours)
Dennis_Pana
Dennis_Pana le 17 Mai 2015
Hi!
I am trying to find out what causes that error. Can anybody give me an idea? Thats my code.
clc;
clear all;
close all;
filename='DOE_Chrysler.xls';
sheet=1;
x1=xlsread(filename,'D4:D28');
x2=xlsread(filename,'E4:E28');
x3=xlsread(filename,'F4:F28');
for i=1:9
for j=1:9;
D(i,j)=sqrt((x1(i)-x1(j))^2+(x2(i)-x2(j))^2+(x3(i)-x3(j))^2);
end
end
for i=1:9;
Min(i)=min(D(i,(i+1):9));
end
D is a symmetric matrix with zeros in the diagonal. I want the minimum values of each row or column of the half matrix because is symmetric by excluding also the diagonal elements which are zero. That is what i am trying to do. Thank you in advance!
  1 commentaire
Image Analyst
Image Analyst le 17 Mai 2015
You forgot to attach 'DOE_Chrysler.xls'. And don't double space your code. Single space it, then highlight and click the {}Code button. Please edit and fix your posting.

Connectez-vous pour commenter.

Réponse acceptée

Walter Roberson
Walter Roberson le 17 Mai 2015
Look at your lines
for i=1:9;
Min(i)=min(D(i,(i+1):9));
end
When i becomes 9 in your loop, then you attempt to take D(9, (9+1):9) which is D(9,10:9) which is going to be the empty matrix because 10:9 gives the empty vector. You then apply min() to the empty vector, getting out an empty vector. You try to assign that empty vector into a definite location Min(i) .

Plus de réponses (0)

Catégories

En savoir plus sur Logical dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by