Question

Write a matlab m. file using loops to find the first factorial that is larger than...

Write a matlab m. file using loops to find the first factorial that is larger than an input number

Homework Answers

Answer #1

%Copy the code below-

%--------------------------------------------------------------------------------------------------------------------------------
prompt = 'input a number';

num = input(prompt); % Input command for number

prod =1; % defining product variable

for i = 1:num+1 % initiating the loop

prod = prod*i;

if prod>num % comparing value of the product with the input number

break;

end

end

fprintf('%i! ', i) % printing the required value of factorial

%---------------------------------------------------------------------------------------------

Know the answer?
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
Similar Questions
Write a MATLAB program to determine the factorial value of an input integer between 1 and...
Write a MATLAB program to determine the factorial value of an input integer between 1 and 30. You may NOT use the built-in factorial function. You must implement it using a for loop. Display the result back to the user with 2 decimal places (yes, 2 decimal places). The result should follow the following format:   The factorial value is *.xx
using matlab: Q)using nested for loops to generate a 3*3 matrix where the element value is...
using matlab: Q)using nested for loops to generate a 3*3 matrix where the element value is equal to the sum of its row and column number, except for the diagonal elements which are zeros
Please use MATLAB to solve it. Develop, debug, and test your own M-file to multiply two...
Please use MATLAB to solve it. Develop, debug, and test your own M-file to multiply two matrices—that is, [X ] = [Y ][Z], where [Y] is m by n and [Z] is n by p. Employ for...end loops to implement the multiplication and include error traps to flag bad cases.
IN MATLAB: Write a function file that takes a vector as an input and returns another...
IN MATLAB: Write a function file that takes a vector as an input and returns another vector with all repeated elements of the original vector. For example, the vector [3 4 1 0 4 -5 7 3] would return the vector [3 4]. Do not use the built-in function "repelem."
Write a program on C++ to calculate and print the factorial of a number using a...
Write a program on C++ to calculate and print the factorial of a number using a for loop. The factorial of a number is the product of all integers up to and including that number, so the factorial of 4 is 4*3*2*1= 24.
Write a MATLAB while-loop code that asks a user to enter an integer number until its...
Write a MATLAB while-loop code that asks a user to enter an integer number until its factorial is smaller than 100.
Question 4 MATLAB a) Write a function file called q4.m containing the following nonlinear equations. ?(?1?2...
Question 4 MATLAB a) Write a function file called q4.m containing the following nonlinear equations. ?(?1?2 ) = ?1 2 + ?2 2 − 26 ?(?1?2 ) = 3?1 2 + 25?2 2 − 100 (1 Mark) b) Use MATLAB’s FSOLVE operator to solve these equations with x1 = 2 and x2 = 2 as your starting point. How many iterations did MATLAB use to solve them? (1 Mark)
A = [-1000:1:1000] write a script file that gives the positive numbers greater than 480 and...
A = [-1000:1:1000] write a script file that gives the positive numbers greater than 480 and divisible by 3. Hint: Use this command if A(i)>480&&(rem(A(i),3)==0) and indeed, if is always accompanied by an end Note: Using Matlab
Q) Write a computer program to test the stability of any continuous-time LTI system.( using Matlab)...
Q) Write a computer program to test the stability of any continuous-time LTI system.( using Matlab) Test your program on the impulse response.   h(t)= e^(-2t) u(t) Attached the program (Matlab) file and a screen shot of the results.
Write a MATLAB code to read the following data sample of fluid properties. 1.       Read data...
Write a MATLAB code to read the following data sample of fluid properties. 1.       Read data from an input file to run the program. The format of the data file is given below. Format of input file # of components (integer) ????,1, ????,1 ,??1, ??1 (critical temperature (K), critical pressure (bar), acentric factor, mole fraction for component 1) [optional lines for additional component if the number of components is greater than 1, for components 2 up to 5] T (system...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT