How do I get my script to produce a 2-D array?

4 ビュー (過去 30 日間)
Nguyen
Nguyen 2015 年 2 月 3 日
編集済み: Rick Rosson 2015 年 2 月 3 日
The script should display a 2-dimensional array with n-rows and two columns: The first column should display the years from 0 to n. The second column should display the account balance at the end of each corresponding year.

採用された回答

Rick Rosson
Rick Rosson 2015 年 2 月 3 日
n = 30;
X = zeros(n+1,2);
X(:,1) = 0:n;
X(:,2) = ...
disp(X);
  2 件のコメント
Nguyen
Nguyen 2015 年 2 月 3 日
編集済み: Nguyen 2015 年 2 月 3 日
This is what I have %compute the growth in a savings account
% get_input prompts for and returns the
% three values entered by the user
initial_bal=input('the initial account balance: $');
rate=input('the annual interest rate:');
time=input('the investment duration in years:');
account_balance=initial_bal.*(1+rate).^time
n=10;
X=zeros(n+1,2);
X(:,1)=0:n;
X(:,2)=account_balance;
disp(X);
How do I get the 2nd column to change with the first column?
Rick Rosson
Rick Rosson 2015 年 2 月 3 日
編集済み: Rick Rosson 2015 年 2 月 3 日
dur = input('the investment duration in years:');
time = 0:dur;
account_balance=initial_bal.*(1+rate).^time;
result = [ time account_balance ];
disp(result);

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File Exchange3-D Scene Control についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by