Question

in MATLAB Given the following script, how many iterations will occur? count = 0; for i...

in MATLAB

Given the following script, how many iterations will occur?

count = 0;

for i = 1:3:10

    count = count + 1;

end

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

Here in the given code:

count = 0;

for i = 1:3:10

    count = count + 1;

end

In the for loop

1 is the initial value

3 is the increment value

10 is the final value

Therefore the number of iterations occur=4

Because from 1 intial to 10 final there is 3 increment so we have 4 iterations

That's why the iterations in this given script are "4"

Add a comment
Know the answer?
Add Answer to:
in MATLAB Given the following script, how many iterations will occur? count = 0; for i...
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
  • MATLAB I need Matlab ouput 4. Solve the following linear set of equations using the script...

    MATLAB I need Matlab ouput 4. Solve the following linear set of equations using the script given below. 53 1 1] x) A=1 3 1 X=(x₂ , B={10} [1 1 3] (45) x=zeros(3,1); AB=[A B] n=size(A,1); for i=1:n-1 P=-(AB(+1:end,i)/AB(1,1)) AB(i+1:end,i:end)=AB(i+1:end,i:end)+P*AB(i,i:end) end for i=n:-1:1 x(1,:)-(AB(i,n+1:end)-AB(1,i+1:n)*x(i+1:n:)YAB(1,1) end

  • DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the...

    DO THIS IN MATLAB PLEASE DO THIS IN MATLAB Create a script file that performs the following calculations. Your script will use the functions you create. Label all graphs appropriately. For this project, do not have your homemade functions fprintf anything, instead have all your fprintf commands within your script. Attach your published script file along with .m files for your functions. Exercise 1. A fundamental iterative method for finding the roots of equations of one-variable is known as Newton's...

  • need a matlab script to show this 1. Apply the bisection routine bisect to find the...

    need a matlab script to show this 1. Apply the bisection routine bisect to find the root of the function f(x)= -1.1 starting from the interval [0,21 (that is, a 0 and b 2), with atol 1.c-8. Gopy 3.6. Exercises 59 required? Does the iteration count match the expectations. (a) How many iterations are based on our convergence analysis? (b) What is the resulting absolute error? Could this absolute error he predicted by our con- vergence analysis? 1. Apply the...

  • In matlab script, thank you! Write a MATLAB script that will generate random integers in the...

    In matlab script, thank you! Write a MATLAB script that will generate random integers in the range from 1 to 100, and print them, until one is finally generated that is greater than 50. The script should print how many attempts it took

  • How many times are the while and for loops run in the following code? Count the...

    How many times are the while and for loops run in the following code? Count the total number of iterations from both the while loop and for loop. p = 32; t = 8; while t <p t=t+ floor(p/pi); for k = 1:2:10 p = p+2; end end Select one: O a. 42 b. 5 c.o o d. 26 o e.30 me to search

  • How many Iterations will this while loop perform? int ico), j(10); cout << "i = "...

    How many Iterations will this while loop perform? int ico), j(10); cout << "i = " << i << endl; cout << "j = " << j << endl; while (i > j) { cout << "j-" « j << endl; j += 2; cout << "i = " << i << endl; } cout << "i = << i << endl; cout << "j = " << j << endl; 5 6 C 8 10 Infinite times Does the...

  • Using the "Newton's Method" Write a MATLAB script to solve for the following nonlinear system of...

    Using the "Newton's Method" Write a MATLAB script to solve for the following nonlinear system of equations: x2 + y2 + z2 = 3 x2 + y2 - z = 1 x + y + z =3 using the initial guess (x,y,z) = (1,0,1), tolerance tol = 1e-7, and maximum number of iterations maxiter = 20.

  • Please write the script for following problem in MATLAB. Write a script with a file name...

    Please write the script for following problem in MATLAB. Write a script with a file name Problem3.m that, when executed, prints 1.99 dollars per unit. How many units will you purchase? [new line] Then control is given back to the user to input a scalar integer quantity. The script then prints out __ units at 1.99 dollars per unit is a total of ___ dollars. [new line] where the first blank is filled with whatever number was inputted by the...

  • Homework No.2 CSC 222 Write a shell script program called "countf.sh" that will count how many...

    Homework No.2 CSC 222 Write a shell script program called "countf.sh" that will count how many files or directories recursively. beside the file counts, also report how many files for each types (directory or regular files). It will either take arguments for specific directories and no argument. If no argument, it will read the current working directory as the starting point. Please also provide -h option to print out how to use your countf.sh program % ./countf.sh % ./countf.sh file1...

  • Use matlab and write script: Please use n = input('Enter the value of n :') not...

    Use matlab and write script: Please use n = input('Enter the value of n :') not the function command. Consider the following equation 6a + 9b + 20c = n The variables a, b, and c can be thought of as the number (non-negative integers) of 6’s, 9’s, and 20’s in n. Note that for a given n, there might be one, multiple, or no solutions for a, b, and c. For example, n = 15 → a = 1...

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