Display just output of function and not the "ans" from the function.
2 views (last 30 days)
monkey_matlab on 20 Sep 2015
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);
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?