Dose any one know any wrong with this function?

Dose any one know any wrong with this function?
function [nom]=intonom(int,conv)
nom=((1+int)^(1/conv)-1)*conv;
I wanna to calculate the interest by using this calculation, but it always say wrong.

6 Kommentare

Birdman
Birdman am 24 Okt. 2017
What do you want to calculate? What do you give as input, scalar, vector? Be more specific and explain it with an example.
Stephen23
Stephen23 am 24 Okt. 2017
Bearbeitet: Stephen23 am 24 Okt. 2017
@a a: what size are int and conv ?
"but it always say wrong."
Please show us the complete error message. This means all of the red text.
PS: using int and conv as variable names, because these will shadow the inbuilt int and conv functions. Always use which to check if a name is already defined.
a a
a a am 24 Okt. 2017
I give int(interest for year), and conv(how many years) as input
a a
a a am 24 Okt. 2017
do we have to define int and conv firstly? when i typing it, it shows, _ _ _ * function [nom]=intonom(int,conv) Error: Function definitions are not permitted in this contex*___
a a
a a am 24 Okt. 2017
@Stephen Cobeldick what i type are: function [nom]=intonom(int,conv) nom=((1+int)^(1/conv)-1)*conv; Error: Function definitions are not permitted in this context.
how can i fixed it?
Walter Roberson
Walter Roberson am 24 Okt. 2017
You have to store that code in a file named intonom.m

Melden Sie sich an, um zu kommentieren.

 Akzeptierte Antwort

KL
KL am 24 Okt. 2017

0 Stimmen

You have to store your code in an m-file under the same name as your function, in your case intonom.m. Once you do that, on the command line, you can type
annual_interest = 0.125;
number_of_years = 8;
result = intonom(annual_intereste,number_of_years)
and then result, according to your formula, is,
result =
0.1187

Weitere Antworten (0)

Kategorien

Mehr zu 関数 finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

a a
am 24 Okt. 2017

Kommentiert:

am 24 Okt. 2017

Community Treasure Hunt

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

Start Hunting!