필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

can someone tell me whats wrong with my coding?

조회 수: 2 (최근 30일)
eri
eri 2012년 10월 1일
마감: MATLAB Answer Bot 2021년 8월 20일
i make this, and it work just fine clear all clc
load matrix4;
b=a
[x,y]=size (b)
d=999999999999999999999999999999999999999999999999999999999;
for n=1:x
b(n,:) = [ ];
c=det(b*b')
if c<d;
d=c
m=n
end
b=a;
end
small=[d]
row=[m]
but then, when i change the matrix, this message appear
Undefined function or variable 'm'.
Error in mystock (line 18)
row=[m]
can someone help me whats wrong?
  댓글 수: 1
Stephen
Stephen 2012년 10월 1일
that error means that the variable 'm' was never created earlier in the code.

답변 (1개)

Andrei Bobrov
Andrei Bobrov 2012년 10월 1일
편집: Andrei Bobrov 2012년 10월 1일
x =size(a,1);
d=inf;
for n=1:x
k = a([1:n-1,n+1:end],:);
c=det(k*k.')
if c < d;
d = c;
row=n;
end
end
small=d;
or
x = size(a,1);
c = zeros(x,1);
for n=1:x
k = a([1:n-1,n+1:end],:);
c(n) = det(k*k.');
end
[small,row] = min(c);
  댓글 수: 2
eri
eri 2012년 10월 1일
what do you mean?
Andrei Bobrov
Andrei Bobrov 2012년 10월 1일
I corrected the your code as you requested.

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by