Improper assignment with rectangular empty matrix.

2 ビュー (過去 30 日間)
Dennis_Pana
Dennis_Pana 2015 年 5 月 17 日
回答済み: Walter Roberson 2015 年 5 月 17 日
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
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
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 件)

カテゴリ

Help Center および File ExchangeMatrix Indexing についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by