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

3 visualizaciones (últimos 30 días)
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)

Respuesta aceptada

Vaclav Rimal
Vaclav Rimal el 15 de Mzo. de 2016
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.

Más respuestas (0)

Categorías

Más información sobre Get Started with MATLAB en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by