Need Help Understanding Matlab Functions: Undefined Error

  • Context: MATLAB 
  • Thread starter Thread starter gfreeman
  • Start date Start date
  • Tags Tags
    Function Matlab
Click For Summary
SUMMARY

The forum discussion centers on resolving an "Undefined function or method 'F'" error encountered while running a MATLAB script. The user attempts to define a recursive function for financial calculations but incorrectly uses function syntax instead of array manipulation. The suggested solution emphasizes the importance of understanding MATLAB's array-based operations and recommends tutorials for better programming practices in MATLAB.

PREREQUISITES
  • Familiarity with MATLAB syntax and functions
  • Understanding of array manipulation in MATLAB
  • Basic knowledge of financial calculations
  • Experience with recursive functions in programming
NEXT STEPS
  • Review MATLAB array operations and indexing
  • Learn about defining functions in MATLAB
  • Explore MATLAB tutorials focused on financial modeling
  • Investigate alternatives like MathCAD for similar calculations
USEFUL FOR

This discussion is beneficial for MATLAB users, particularly those involved in financial modeling, as well as beginners seeking to understand MATLAB's function and array handling.

gfreeman
Messages
1
Reaction score
0
Hi,

I'm trying to help my sister with a Matlab work, but I'haven't work with MATLAB for a long time so I'm having some difficulties.

I'm trying to run this code but it gives me an error : Undefined function or method 'F' for input arguments of type 'double'. F(x)=(1-T)*F(x-1);

Code:
x=input('Number of years:');
D=input('loaned value:');
T=input('growing rate:');

F(0)=input('First year payment:');

K(0)=input('First year rate:');

EA(0)=D;
EP(0)=D;
for i=1:n
  F(x)=(1+T)*F(x-1);
  FA(x)=0.5*F(x);
  EA(x)=(EA(x-1)-FA(x))*(1+0.01);
  EP(x)=(EP(x-1)-F(x))-(1+K(x));
  K(x)=K(x-1)*EP(x)/EP(x-1);
end

the purpose of the work is calculate the value for EA(x) and EP(x).

thanks
 
Last edited:
Physics news on Phys.org
This is not how you write Matlab scripts. While it is possible to define a function in Matlab, one primarily works on arrays (vectors and matrices) instead. Suggest you try one of their tutorials to get a feel for how to program Matlab, or switch to a different language like MathCAD.
 

Similar threads

  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 5 ·
Replies
5
Views
3K
  • · Replies 8 ·
Replies
8
Views
3K
  • · Replies 5 ·
Replies
5
Views
4K
  • · Replies 6 ·
Replies
6
Views
2K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 18 ·
Replies
18
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
  • · Replies 3 ·
Replies
3
Views
2K