Improper assignment with rectangular empty matrix.
1 次查看(过去 30 天)
显示 更早的评论
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 个评论
Image Analyst
2015-5-17
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.
采纳的回答
Walter Roberson
2015-5-17
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 个评论
更多回答(0 个)
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Logical 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!