Effacer les filtres
Effacer les filtres

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

1 vue (au cours des 30 derniers jours)
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?
%

Réponse acceptée

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

Plus de réponses (0)

Catégories

En savoir plus sur Programming dans Help Center et File Exchange

Tags

Produits

Community Treasure Hunt

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

Start Hunting!

Translated by