Index Exceeds Matrix Dimentions
1 view (last 30 days)
Show older comments
Nathan Adkins
on 2 Mar 2015
Commented: Star Strider
on 2 Mar 2015
Ive written the following script
function futureworth(p,i,n)
nn=0:n; %lets the exponent know that its a matrix from 0 to n
F = p*(1+i).^nn;
y=[nn;F]; %displays table with the year and future worth
fprintf('Year Future Worth');
fprintf('%5d %14.2f\n',y);
end
But when I type "futureworth(100000,0.05,10)" in the command window I immediately get the error message "index exceeds matrix dimensions"
If anyone has any solutions to my problem please help!
0 Comments
Accepted Answer
Star Strider
on 2 Mar 2015
Edited: Star Strider
on 2 Mar 2015
You have to save it in your MATLAB user file path in its own .m-file as futureworth.m
If you created a variable named ‘futureworth’, you have to clear it first. See if:
clear futureworth
futureworth(100000,0.05,10)
works.
More Answers (0)
See Also
Categories
Find more on Matrix Indexing in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!