How do I suppress answer in Matlab?
Afficher commentaires plus anciens
Hi, I'm trying to calculate e^x for some value of x using the taylor expansion approximation
T_n(x) = Sum (x^k/k!)
And I have managed to do this using the following m-file
function T = findexp(x,n) %findexp, function to evaluate e^x T(1)=1; for i = 2:n+1 T(i) = T(i-1)+x^(i-1)/(factorial(i-1)); if i == n+1 fprintf(1,'T(%d) = %1.15e\n',x,T(i)); end end
However, when I then type findexp(1,25) for example the output is
T(1) = 2.718281828459046e+000
ans =
Columns 1 through 8
1.0000 2.0000 2.5000 2.6667 2.7083 2.7167 2.7181 2.7183
Columns 9 through 16
2.7183 2.7183 2.7183 2.7183 2.7183 2.7183 2.7183 2.7183
Columns 17 through 24
2.7183 2.7183 2.7183 2.7183 2.7183 2.7183 2.7183 2.7183
Columns 25 through 26
2.7183 2.7183
How do I suppress the columns and just show the T(1) part.
Sorry I realise this is a really amateurish question I just have done very little Matlab programming before.
Thanks in advance
1 commentaire
Parag
le 23 Jan 2012
I have the same problem with optimizer function called "fmincon" as per the help files the output of this functon can not be switched off. You can supress the final result but not the intermediate output generated by the calculations. I have tried all kinds of options associated with this function but I still can not supress the output. Is there any way to supress thd output of an entire matlab code on command window? I am already storing the output variables I need so it doesnt matter if I get output on command window or not.
Réponse acceptée
Plus de réponses (0)
Catégories
En savoir plus sur Function Creation dans Centre d'aide et File Exchange
Produits
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!