Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Use Matlab to write the codes of the following problems. General Instructions •

ID: 3183932 • Letter: U

Question

Use Matlab to write the codes of the following problems.
General Instructions
• You must write your code in this MATLAB script file. • Write your code in an organized and professional way with appropriate syntax and output suppres- sion. Any questions that require written explanation should be commented below your code for that assignment problem. • SUPPRESS OUTPUT WITH A SEMICOLON (;) UNLESS IT SAYS OTHERWISE.
Problems
1. Write the code that generates a random number between 0 and 1 and saves the result to a variable named rand 0 1. 2. Write the code that generates a random number between 0 and 6 and saves the result to a variable named rand 0 6. 3. Write the code that generates a random number between 2 and 8 and saves the result to a variable named rand 2 8. 4. Write the code that generates a random number between a and b and saves the result to a variable named rand a b. 5. Using symbolic variables, create the following function: f(x) = x2 and save it to a variable named f symb. 6. Using anonymous functions, create the same function as in the previous problem and save it to a variable named f anon. 7. Evaluate the function f symb at x = 3 and save the answer to a variable named y1. 8. Evaluate the function f anon at x = 3 and save the answer to a variable named y2. 9. Write the code that creates a movie file called ”movie.avi” which has only 1 frame. This frame should contain the graph of the function y = x2.    Use Matlab to write the codes of the following problems.
General Instructions
• You must write your code in this MATLAB script file. • Write your code in an organized and professional way with appropriate syntax and output suppres- sion. Any questions that require written explanation should be commented below your code for that assignment problem. • SUPPRESS OUTPUT WITH A SEMICOLON (;) UNLESS IT SAYS OTHERWISE.
Problems
1. Write the code that generates a random number between 0 and 1 and saves the result to a variable named rand 0 1. 2. Write the code that generates a random number between 0 and 6 and saves the result to a variable named rand 0 6. 3. Write the code that generates a random number between 2 and 8 and saves the result to a variable named rand 2 8. 4. Write the code that generates a random number between a and b and saves the result to a variable named rand a b. 5. Using symbolic variables, create the following function: f(x) = x2 and save it to a variable named f symb. 6. Using anonymous functions, create the same function as in the previous problem and save it to a variable named f anon. 7. Evaluate the function f symb at x = 3 and save the answer to a variable named y1. 8. Evaluate the function f anon at x = 3 and save the answer to a variable named y2. 9. Write the code that creates a movie file called ”movie.avi” which has only 1 frame. This frame should contain the graph of the function y = x2.    Use Matlab to write the codes of the following problems.
General Instructions
• You must write your code in this MATLAB script file. • Write your code in an organized and professional way with appropriate syntax and output suppres- sion. Any questions that require written explanation should be commented below your code for that assignment problem. • SUPPRESS OUTPUT WITH A SEMICOLON (;) UNLESS IT SAYS OTHERWISE.
Problems
1. Write the code that generates a random number between 0 and 1 and saves the result to a variable named rand 0 1. 2. Write the code that generates a random number between 0 and 6 and saves the result to a variable named rand 0 6. 3. Write the code that generates a random number between 2 and 8 and saves the result to a variable named rand 2 8. 4. Write the code that generates a random number between a and b and saves the result to a variable named rand a b. 5. Using symbolic variables, create the following function: f(x) = x2 and save it to a variable named f symb. 6. Using anonymous functions, create the same function as in the previous problem and save it to a variable named f anon. 7. Evaluate the function f symb at x = 3 and save the answer to a variable named y1. 8. Evaluate the function f anon at x = 3 and save the answer to a variable named y2. 9. Write the code that creates a movie file called ”movie.avi” which has only 1 frame. This frame should contain the graph of the function y = x2.   

Explanation / Answer

% 1. Code that generates a random number between 0 and 1

rand_0_1 = rand;

% 2. Code that generates a random number between 0 and 6

rand_0_6 = 6*rand;

% 3. Code that generates a random number between 2 and 8

rand_2_8 = 2 + 6*rand;

% 4. Code that generates a random number between a and b

rand_a_b = a + (b-a)*rand;

% 5. Code for creating function f(x) = x^2 symbolic

syms x;
f_symb = x^2;

% 6. Code for creating function f(x) = x^2 anonymous function

f_anon = @(x) x^2;


% 7. Evaluating the function f at x =3 symbolically

y1 = subs(f_symb,3);


% 8. Evaluating the function f at x=3 function handle

y2 = f_anon(3);

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote