Dismiss Notice
Join Physics Forums Today!
The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

Help with function in Matlab

  1. Mar 20, 2012 #1
    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 (Text):

    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: Mar 20, 2012
  2. jcsd
  3. Mar 20, 2012 #2

    marcusl

    User Avatar
    Science Advisor
    Gold Member

    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.
     
Know someone interested in this topic? Share this thread via Reddit, Google+, Twitter, or Facebook




Similar Discussions: Help with function in Matlab
  1. Matlab function help (Replies: 3)

  2. MATLAB function help! (Replies: 1)

Loading...