Improper assignment with rectangular empty matrix.
1 view (last 30 days)
Show older comments
Dennis_Pana
on 17 May 2015
Answered: Walter Roberson
on 17 May 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 Comment
Image Analyst
on 17 May 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.
Accepted Answer
Walter Roberson
on 17 May 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) .
0 Comments
More Answers (0)
See Also
Categories
Find more on Logical in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!