Question

5.i) What will be the output of the script: for i-1:7 for j- 1:i fprintf(%d, j) end fprintf(\n) % start a new line. end 5 (i) For ax2 + bxc 0, the value of x is given by 2a Write a MATLAB function quadrasol () that will have three inputs ( a,b, and c) and two outputs corresponding to the solutions of the equation. It may be more compact if you defined another variable d for the term inside the square root within your function. Show how you will call the function from the command prompt to obtain the solution for the quadratic x2 -3x +2 0

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

Please Note:

As HOMEWORKLIB Answering Guidelines, I have answered the first question.

Please Re-post for the other Questions

Answer)

5.i)

The output of the script:

for i = 1:7

for j=1:i

fprintf('%d',j)

end

fprintf('\n')

end

Program in C:

for(int i =1;i<=7;i++) {

for(int j=1;j<=i;j++){

printf("%d",j);

}

printf("\n");

}

Output:

1   

12

123   

1234

12345   

123456

1234567

Add a comment
Know the answer?
Add Answer to:
5.i) What will be the output of the script: for i-1:7 for j- 1:i fprintf(%d", j)...
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
  • 4-6 on matlab 4. Write a program in a script file that determines the real roots...

    4-6 on matlab 4. Write a program in a script file that determines the real roots of a quadratic equation ax2+bx+c 0 When the file runs, it asks the user to enter the values of the constants a, b, and c. To calculate the roots of the equation the program calculates the discriminant D, given by: D b2-4ac When D 0, the program displays message "The equation has two roots," and the roots are displayed in the next line. When...

  • Using matlab and if/else statement please! Write a function that determines the real roots of a...

    Using matlab and if/else statement please! Write a function that determines the real roots of a quadratic equation ax2 + bx + c = 0. To calculate the roots of the equation, the function calculates the discriminant D, given by: D = b2-4ac If D> 0, the code should display "The equation has two roots" and print the values on a new line. If D 0, the code should display "The equation has one root.", and print the value on...

  • Problem 4 (7 points): What is the output (printed to command prompt) of the following code...

    Problem 4 (7 points): What is the output (printed to command prompt) of the following code (Exam2Prob4.m)? DO NOT USE MATLAB for solving this problem. ZERO CREDIT if all steps are not shown. You should explain the output of each code as if you are executing the code. (answer 2 points; process, with each step - 8 points) Exam2 Prob4.m clc; clear; close all; p=4; q = 3; r5; (x, y] = user Defined (p, q, r); fprintf('x- $d, y=%d',x,y);...

  • clc,clear N =input('Enter positive number\n'); d=0; x = i; for i= 2:N-1 if (mod(N,i)==0) for j=...

    clc,clear N =input('Enter positive number\n'); d=0; x = i; for i= 2:N-1 if (mod(N,i)==0) for j= i:N if (mod(i,j)==0) d = d+1; fprintf('%d\t \n',i); end    end end How can I determine the Positive PRIME factors only out of this code? What should I debug? (MATLAB)

  • Page 73, as mentioned in the stated question, is provided below 1. Consider a new root-finding...

    Page 73, as mentioned in the stated question, is provided below 1. Consider a new root-finding method for solving f(x) = 0. Successive guesses for the root are generated from the following recurrence formula: Xn+1 = In f(xn) fhen + f(xn)] – F(Xn) (1) Write a user-defined function with the function call: [r, n] = Root fun (f, xl, tol, N) The inputs and outputs are the same as for the user-defined function Newton described on page 73 of Methods....

  • I only need help on doing number 4 LON-CAPA COurse ConSSOE-First ear-SprirASSGT9 (1)pd softEdge elackboard Conter...

    I only need help on doing number 4 LON-CAPA COurse ConSSOE-First ear-SprirASSGT9 (1)pd softEdge elackboard Conter 4d Metro Boomin No mpstate/Downloads/ASSGT9%20(1) pdf Users/april/AppData/Local/Pac Your task: Design, code, and debug a MATLAB script that: (1) Asks the user (use a nenu) what kind of function (m-file or anonymous function) will be used. If an m-file, have the user enter the filename; if an anonymous function, have the user enter the function (hint: use MATLAB's eval function in your script to appropriately...

  • Please answer 1c, use MATLAB, and paste your entire script in your answer so that I...

    Please answer 1c, use MATLAB, and paste your entire script in your answer so that I can copy and paste to see if it works. Problem #1 400g triangle square pentagon hexagon Figure 1 For a closed geometric figure composed of straight lines (Figure 1), the interior angles in the figure must add to (n-2)(180) where n is the number of sides. Required Tasks a) Write a script that prompts the user to select from one of the following shapes:...

  • Newton's Method in MATLAB During this module, we are going to use Newton's method to compute...

    Newton's Method in MATLAB During this module, we are going to use Newton's method to compute the root(s) of the function f(x) = x° + 3x² – 2x – 4 Since we need an initial approximation ('guess') of each root to use in Newton's method, let's plot the function f(x) to see many roots there are, and approximately where they lie. Exercise 1 Use MATLAB to create a plot of the function f(x) that clearly shows the locations of its...

  • 5) What is the output of the following program? (5 Marks) e-0 n-1000000; for i-1 to n if (normrnd...

    5) What is the output of the following program? (5 Marks) e-0 n-1000000; for i-1 to n if (normrnd(1, 0.25)<0) e-e+1 end (if) end (for) print (e/n Note: normrnd(μ, σ) is a Matlab function 5) What is the output of the following program? (5 Marks) e-0 n-1000000; for i-1 to n if (normrnd(1, 0.25)

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