I created a function to calculate a linear system with 5 unknowns (A1 to A5), which has as output argument 'Ai' and input 'A and b' which are respectively a Matrix and Vector. The values of A and b are assigned, but I did not put it here.
At the end of the function I get the values of Ai (which are 5). But I need to use the Ai values outside of my function!
FOLLOW THE FUNCTION:
function Ai = gauss(A,b)
%% dimensao da matriz. linha, coluna
[l,c]=size(A);
%% eliminação
for i=1:l-1
for j=i+1:l;
%% definição da constante para zerar as linhas
constante=A(j,i)/A(i,i);
for k=i+1:l;
%% operação linear para eliminar as linhas
A(j,k)=A(j,k)-constante*A(i,k);
end
A(j,i)=0;
b(j)=b(j)-constante*b(i);
end
end
%% Resolução do sistema
%% função Ai recebe um array de zeros
Ai=zeros(l,1);
fprintf('SOLUÇÃO DO SISTEMA:\n\n');
for i=l:-1:1;
soma=0;
for k=i+1:l;
soma=soma+A(i,k)*Ai(k);
end
Ai(i)=(b(i)-soma)/A(i,i);
end
end
y=x^2+x;
I want to multiply each value of Ai (which is 5) by the expression below that is outside the gauss function.
y=x^2+x;
But how to use the values of Ai out of function?