Borrar filtros
Borrar filtros

Display just output of function and not the "ans" from the function.

1 visualización (últimos 30 días)
For this simple function that I have:
% This code takes in two inputs, Z and X.
% eg. Z = [ 2; 7], X = [ 1, 1; 1, 2]. From these two inputs, the
% values for theta1,LS and theta2,LS are calculated.
%__________________________________________________________________________
function theta1LS_theta2LS = LSE(Z,X)
X_transpose = X.'; % Transpose of Matrix X
Theta = inv(X_transpose * X)*X_transpose*Z; % Theta
theta1LS_theta2LS = inv(X_transpose * X)*X_transpose*Z; % Theta
theta1LS = theta1LS_theta2LS(1);
theta2LS = theta1LS_theta2LS(2);
fprintf(' theta1LS = %6.3f \n theta1LS = %6.3f \n',theta1LS, theta2LS);
end
I just wanted to display the theta1LS and theta2LS numbers.
I do get the theta1LS and theta2LS numbers, but then at the end, I also get ans = -3.0000 5.0000.
How to just get the theta1LS and theta2LS numbers to display and not the "ans" numbers?
%

Respuesta aceptada

Walter Roberson
Walter Roberson el 20 de Sept. de 2015
Prob_3_7_new(Z,X);
Notice the semi-colon after the expression.

Más respuestas (0)

Categorías

Más información sobre Programming en Help Center y File Exchange.

Etiquetas

Productos

Community Treasure Hunt

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

Start Hunting!

Translated by