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

1 次查看(过去 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 中查找有关 Get Started with MATLAB 的更多信息

Community Treasure Hunt

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

Start Hunting!

Translated by