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

generate a random integer in the inclusive range from 2 to 5 loop that many time

ID: 3596130 • Letter: G

Question

generate a random integer in the inclusive range from 2 to 5 loop that many times to - prompt the user for a number · print the sum of the numbers entered so fe h one d amal place 8. Write a script that will load data from a file into a matrix Create the data file first and make sure that there is the same number of values on every line in the file so that it can be loaded into a matrix. Using a for loop, it will then create a subplot for every row in the matrix, and will plot the numbers from each row element in the Figure Window Write the code that will prompt the user for 4 numbers, and store them in a vector Make sure that you preallocate the vector Write a for loop that will print the elements from a vector variable in sentence format, regardless of the length of the vector. For example, if this is the vector 9. 10. vec-(5.511 3.45 this would be the result Element 1 is 5.50. Element 2 is 11,00 Element 3 is 3.45 The for loop should work regardless of how many elements are in the vector Execute this script and be amazed by the results! You can try more points to get a clearer picture, but it may take a while to run clear cif x = rand, y rand; plot(Xy) hold on ford E 1:10000 choic-roundtrand-2): irchoic-O x-x/2 ys y12, elsef choic 1 x = (x+ 1)/2; y # y/2: etsex-cx+0 5)/2; y-cy+1)/2, end plot(x,y) hold on end 11. 12. A machine cuts N pieces of a pipe. After each cut, each piece of pipe is weighed and its length is measured, these 2 values are then stored in a file called pipe dat (first the weight and then the length on each line of the file). Ignoring units, the weight is supposed to be between 2.1 and 2.3, inclusive, and the length is supposed to be between 10.3 and 10.4, inclusive. The following is just the beginning of what will be a long script to work with these data. For now, the script will just count how many rejects there are. A reject is any piece of pipe that has an invalid weight and/or length. For a simple example, if N is 3 (meaning three lines in the file) and the file stores

Explanation / Answer

%matlab code

clc;
close all;
clear all;
vec = [5.5 11 3.45];
for i=1:length(vec)
elm = vec(i);
fprintf('element %d is %2.2f ',i,elm);
end


Output:-

element 1 is 5.50
element 2 is 11.00
element 3 is 3.45