Borrar filtros
Borrar filtros

Improper assignment with rectangular empty matrix.

3 visualizaciones (últimos 30 días)
Dennis_Pana
Dennis_Pana el 17 de Mayo de 2015
Respondida: Walter Roberson el 17 de Mayo de 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 comentario
Image Analyst
Image Analyst el 17 de Mayo de 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.

Iniciar sesión para comentar.

Respuesta aceptada

Walter Roberson
Walter Roberson el 17 de Mayo de 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) .

Más respuestas (0)

Categorías

Más información sobre Logical en Help Center y File Exchange.

Community Treasure Hunt

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

Start Hunting!

Translated by