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

19 ビュー (過去 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 Center および File ExchangeLoops and Conditional Statements についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by