How do I eliminate the "ans = " at the end of my function?

This is my function:
function fvalue = valcomp
clear all
clc
P = input('Enter initial amount ($): ');
disp(' ');
i = input('Enter interest rate (decimal): ');
disp(' ');
n = input('Enter number of periods: ');
disp(' ');
fvalue = P*(1+i)^n;
x=fvalue;
fprintf('Number of Periods: Future Value:\n\n');
fprintf('%5d %10.2f',n,x);
and this is what it returns:
Enter initial amount ($): 100000
Enter interest rate (decimal): .05
Enter number of periods: 10
Number of Periods: Future Value:
10 162889.46
ans =
1.6289e+05
EDU>>
I would like to figure out how to eliminate the "ans =" at the end

回答 (1 件)

Kaustubha Govind
Kaustubha Govind 2012 年 2 月 1 日

0 投票

How are you calling the function? You need to put a semicolon at the end of your call:
>> valcomp;

1 件のコメント

Ryan
Ryan 2012 年 2 月 1 日
That works perfectly, it always seems to be something so simple. Thanks so much.

サインインしてコメントする。

カテゴリ

ヘルプ センター および File ExchangeVariables についてさらに検索

タグ

質問済み:

2012 年 2 月 1 日

Community Treasure Hunt

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

Start Hunting!

Translated by