Question
Please do the following Matlab problem, 1.Write a for loop ranging from 3 to 5. In the loop, print the value of the loop index
Please do the following Matlab problem,
1.Write a for loop ranging from 3 to 5. In the loop, print the value of the loop index to the screen using fprintf in the following format:
Value is n
where n is not the letter n, but is the value of the associated loop index.
2.Write a while loop that produces the same result as problem 1. Youll need to initialize an index, and then increment it within the loop.
3.Write a function with one input and no outputs. The input will be an integer. The resulting value which will print to the screen will be the product of all integers from 2 through the input value, which is the factorial of the number. After the loop, also calculate the factorial of the number using the built-in MATLAB function factorial. Print the value of the factorial calculated in the loop and the value from the MATLAB function to the screen. Test the function using the input value 10, which should result in an answer of 3,628,800.
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started