Undefined function or variable 'f'. Error in Pivotare (line 13) f := proc(b, n, m) WHAT TO DO ?

조회 수: 6 (최근 30일)
MATLAB code
clc;
rel=1;
while (rel==1)
fprintf('Introduceti numarul de linii:\n');
n=input('n=');
fprintf('Introduceti numarul de coloane:\n');
m=input('m=');
for i=1:n %Introducerea liniilor primei matrice
fprintf('\nLinia %g:',i);
b(i,:)=input(' ');
function f=proc(b, n, m);
local a i j k aux;
begin
a=b;
if (n<=m)
nmin=n;
else
nmin=m;
end
for k=1:nmin
aux=abs(a(k,k));
i=k;
for j=k+1:n
if aux<abs(a(j,k))
aux=abs(a(j,k));
i=j;
end
end
for j=k:m;
aux=a(k,j);
a(k,j)=a(i,j);
a(i,j)=aux;
end
if a(k,k)~=0
for j=k+1:m
a(k,j)=a(k,j)/a(k, k);
end
a(k,k)=1;
for i=k+1:n
for j=k+1:m
a(i,j) = a(i,j)-a(k,j)*a(i,k);
end
end
for i=k+1:n
a(i,k)=0;
end
end end
end f(a,n,m); fprintf('%g', f)

채택된 답변

Vaclav Rimal
Vaclav Rimal 2016년 3월 15일
You cannot nest a function definition in the middle of a code. Instead, place the definition of your function proc in the end of the file - or, better, into a separate one. And avoid begin keyword which does not exist in MATLAB.

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by