Question

In the MATLAB code below what does the line:

A(i) = 0;

do?

Is A(i) just a variable or does in index something?

P=1000; r=0.01; n=1; f for loop to calculate monthly interest and yearly interest for i=1:10 A(i)=0; for j=1:12 Am=P* (1+r)^n

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Answer:

for loop is iterating from 1 to 10.
so, A(i) indicates A(1), A(2), ... to A(10)
so, all of the elements of A are initialized to 0 inside the loop.
Add a comment
Know the answer?
Add Answer to:
In the MATLAB code below what does the line: A(i) = 0; do? Is A(i) just...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Using Matlab. I can't seem to get the fprintf part to display the values in 2...

    Using Matlab. I can't seem to get the fprintf part to display the values in 2 columns. Could someone help me with that Before calculators were readily available (about 1974), students used tables to determine the values of mathematical functions like sine, cosine, and log. Create such a table for sine, using the following steps: • Create a vector of angle values from 0 to 27 in increments of T/10. • Calculate the sine of each of the angles, and...

  • 22Hello, I am keep getting this warning on MATLAB; ''Assignment has more non-singleton rhs dimensions than...

    22Hello, I am keep getting this warning on MATLAB; ''Assignment has more non-singleton rhs dimensions than non-singleton subscripts'' what does it mean?? the matlab code is; %%Use the built-in min and max function to find minimum element of matrix A and maximum element of matrix B for each column fprintf('Matrix from minimum of A maximum of B: \n'); A = [22,0;12 -4]; B = [14,4;-3 9]; R(1,:) = max(B); R(2,:) = min(A); disp(R); can you help me?? thank you so...

  • Need help with MATLAB, what code should be added to print the graph of the trapezoid rule code be...

    Need help with MATLAB, what code should be added to print the graph of the trapezoid rule code below? %%Matlab code for Question 5. syms X y intlx exp(x),0,2); %integration of x*exp(x) fprintf("htlntegration of x"2*exp(x) for [O 3] is %2.5f.\n,y) %Integration using Trapizoidal rule nn [100 1000]; for ii 1:2 a:0; b-3; %Integration limit ns-1:nn(i) integral Values-zeros(size(ns)); ourFunction-@(x) x.*2.*exp(x); for n-ns val(n)-trapizoidal (ourFunction,a,b,nn(i); end fprintf nlntegration of x 2*exp(x) using Trapizoidal rule for [O 3]\n') fprintf('1tTrapizoidal integration value for n-%d...

  • Matlab fprintf help This is the question: I have already done part a, I need help...

    Matlab fprintf help This is the question: I have already done part a, I need help with part b. This is my current code: % array of Pounds to convert to Kilograms weight_pound = [50.543 65.676 75.343 80.937] % for Loop that calls from the array weight_pounds for index=1:4 %Convert weight from Pounds to Kilograms     weight_kg = weight_pound*0.453592 %Print out the conversion % ‘%5.2f’ for 2 decimals for Kilograms % ’%5.0f’ for no decimals in pounds     fprintf(‘%5.2f kg...

  • 8 0/1 point How could the following code be re-written with a while loop? % find...

    8 0/1 point How could the following code be re-written with a while loop? % find the index of the first value in A divisible by 3 index = 0; for i = length(A):-1:1 if mod(A(i),3) == 0 index = 1; end end if index > 0 fprintf('The index of the first number divisible by 3 is %d\n', index); end O i=1; while i < length(A) if mod(A(1),3) == 0 index = 1; end SP ^00 201 Tprint("The index of...

  • Numerical Methods (matlab code) QUESTION 2 A friend wants to deposit $2000 into a savings account....

    Numerical Methods (matlab code) QUESTION 2 A friend wants to deposit $2000 into a savings account. She goes to two banks and is offered competing interest rates for the account. Bank 1 has a 10% interest rate, and compounds once annually. Bank 2 has an 9% interest rate, but compounds monthly. Use the following annually compounded interest formula, A= P(1+r) where A is the accumulated amount, P is the principal amount deposited, r is the annual interest rate (as a...

  • Guys need ur help about matlab.. i just want to compare answers if mine are correct.....

    Guys need ur help about matlab.. i just want to compare answers if mine are correct.. Please show clear and correct answer.. 2. Produce the "output' for the following complete MATLAB Script program (Le. Show eyepything ouiput the suren for x-0:2 for y 0:1 fprintf(%d %d\n", x, y); end fprintf('They are equalln'); end end

  • MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts...

    MATLAB help! I have some MATLAB Assignment to do, the proffesor requires all the small parts in order to get full credit. Help me out, thank you f LAB SECTION NAME HW6P3 (30 points) following are infinite series representations of the function, un pra i a script file HW6P3 that determines the value of the function from the sum of the series for a given value of x. The program (1 pt) must prompt the user to enter a value...

  • MATLAB ONLY!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, USE FOR LOOPS....

    MATLAB ONLY!! PLEASE WRITE IN COMPUTER SO I CAN COPY PASTE!!! ANSWER COMPLETELY, USE FOR LOOPS. THE PROGRAM TO BE MODIFIED IS THE NEXT ONE: clc clear % Approximate the value of e ^ x using the Taylor Series x = input( 'Enter the value of x for e^x. x = ' ); t = input( 'Enter the amount of desired terms. t = ' ); i = 1; e_taylor = 0; % initializing the variable for the accumulator while...

  • Change the following code to give only the first 2 picks; or 3 picks (Matlab) %...

    Change the following code to give only the first 2 picks; or 3 picks (Matlab) % colors for ball colors = ["red", "blue", "green", "yellow"]; % initial probabilites % change as required p = [0.20, 0.25, 0.35, 0.20]; % cumulative sum of p c = cumsum(p); % continue drawing until all are drawn while(size(p) > 0) % generate a random number r = rand(); % draw ball according to random number ball = 0; for i = 1:size(p, 2) if(r...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT