Results 1 to 4 of 4

Math Help - Can anyone spot my error?

  1. #1
    Newbie
    Joined
    Feb 2010
    Posts
    1

    Can anyone spot my error?

    Im trying to create a system that calculates interest over ten years but for some reason i keep getting an error message.
    I am about 99% this is the correct text for the program yet there is an error message of: Error using ==> power
    Matrix dimensions must agree.
    So my t vector is not agreeing with my interest formula or what?

    delete g114x05.txt; diary g0114x05.txt
    clear; clc; close all; echo on
    %
    % Gilat 114/05
    %
    %Script determining account balance in a savings account
    r=('Enter Interest Rate (as a percent) :')
    P=('Enter Principal :')
    t=[1:10];
    A=P*(1+r/100).^t;
    echo off;
    table=[t' A']

    fprintf(' \n')
    fprintf('Time Amount \n')
    fprintf('(yrs) ($) \n')
    fprintf('------------------------ \n')
    fprintf('%4i %8.2f \n',table')
    echo off ;diary off;
    Follow Math Help Forum on Facebook and Google+

  2. #2
    zeg
    zeg is offline
    Newbie
    Joined
    Feb 2010
    From
    Portland, OR
    Posts
    12

    not sure what language but

    A is not defined with the same dimensions as t. Hence your error message, the power t appears to have 10 different values and A appears to only hold a single value. A needs to be same dimensions as t, or maybe loop through t and write each value to file as it is computed?
    Follow Math Help Forum on Facebook and Google+

  3. #3
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by DougfWalters View Post
    Im trying to create a system that calculates interest over ten years but for some reason i keep getting an error message.
    I am about 99% this is the correct text for the program yet there is an error message of: Error using ==> power
    Matrix dimensions must agree.
    So my t vector is not agreeing with my interest formula or what?

    delete g114x05.txt; diary g0114x05.txt
    clear; clc; close all; echo on
    %
    % Gilat 114/05
    %
    %Script determining account balance in a savings account
    r=('Enter Interest Rate (as a percent) :')
    P=('Enter Principal :')
    t=[1:10];
    A=P*(1+r/100).^t;
    echo off;
    table=[t' A']

    fprintf(' \n')
    fprintf('Time Amount \n')
    fprintf('(yrs) ($) \n')
    fprintf('------------------------ \n')
    fprintf('%4i %8.2f \n',table')
    echo off ;diary off;
    The only line this could occur on is OK

    CB
    Follow Math Help Forum on Facebook and Google+

  4. #4
    Grand Panjandrum
    Joined
    Nov 2005
    From
    someplace
    Posts
    14,972
    Thanks
    4
    Quote Originally Posted by zeg View Post
    A is not defined with the same dimensions as t. Hence your error message, the power t appears to have 10 different values and A appears to only hold a single value. A needs to be same dimensions as t, or maybe loop through t and write each value to file as it is computed?
    It is Matlab and as A is underined it takes the dimensions of what it is assigned as. The error message is what you would bet if using "^" rather than ".^".

    CB
    Follow Math Help Forum on Facebook and Google+

Similar Math Help Forum Discussions

  1. coordinates of a paint spot
    Posted in the Trigonometry Forum
    Replies: 4
    Last Post: May 27th 2011, 11:09 AM
  2. Spot my mistake please...
    Posted in the Statistics Forum
    Replies: 4
    Last Post: September 8th 2010, 04:15 AM
  3. Odd proof - Can you spot the error?
    Posted in the Math Puzzles Forum
    Replies: 14
    Last Post: March 8th 2010, 04:57 PM
  4. How do you spot it's a substitution
    Posted in the Calculus Forum
    Replies: 1
    Last Post: June 17th 2009, 08:17 AM
  5. Spot the formula
    Posted in the Algebra Forum
    Replies: 4
    Last Post: July 25th 2008, 09:54 PM

Search Tags


/mathhelpforum @mathhelpforum