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

1 次查看(过去 30 天)
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?
%

采纳的回答

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

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Programming 的更多信息

标签

产品

Community Treasure Hunt

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

Start Hunting!

Translated by