Question

In: Computer Science

The language is MATLAB Write a function that will generate three random integers, each in the...

The language is MATLAB

Write a function that will generate three random integers, each in the inclusive range from 10 to 80. It will then return a string consisting of the three integers joined together, and also a character vector consisting of the three integers joined together. For example, if the random integers are 11, 29, and 76, the string that is returned will be "112976" and the character vector that is returned will be '112976'.

I'm really confused on this one, so if anyone can help me out, I'd appreciate it!

Solutions

Expert Solution


%   MATLAB Program to generate random string and character vector

function [strVector, charVector] = RandomCharcterVector()
    
    strVector = string(mat2str(randi([10,80],1,3)));
    
    strVector = erase(strVector, '[');
    strVector = erase(strVector, ' ');
    strVector = erase(strVector, ']');
    
    charVector = convertStringsToChars(strVector);

end


Related Solutions

Write a program that uses a custom function to generate a specified number of random integers...
Write a program that uses a custom function to generate a specified number of random integers in a specified range. This custom function should take three arguments; the number of integers to generate, the lower limit for the range, and the upper limit for the range. Values for these arguments should be entered by the user in main. The custom function should display the random integers on one line separated by single spaces. The function should also report how many...
Write a MATLAB function that will generate chi-square random variables with v degrees of freedom by...
Write a MATLAB function that will generate chi-square random variables with v degrees of freedom by generating v standard normal, squaring them and then adding them up. This uses the fact that is chi-square with v degrees of freedom. Generate some random variables and plot in a histogram. The degrees of freedom should be an input argument set by the user.
(MATLAB) Write a script that would create a 3x5 matrix of random integers and write this...
(MATLAB) Write a script that would create a 3x5 matrix of random integers and write this new matrix to a file called “Assignment3_Question5.dat”.
Write a function that will generate an array of random numbers. It needs to:
DO IN C++Write a function that will generate an array of random numbers. It needs to:Take 3 integers as parameters-The first is the minimum value-the second is the maximum value-the third is the size of the new array-create a dynamically allocated array of the correct size-generate a random number (between min and max) for each element in the array-return a pointer to the arrayCreate a main() function that tests the above function and displays the values in the random array.
Write Java code to generate 100 random integers ranging from 0..9, inserting each element into an...
Write Java code to generate 100 random integers ranging from 0..9, inserting each element into an ArrayList. Then search for the first instance of the number 3, print the position, and then remove it from the list.
Write a program that does the following: Generate an array of 20 random integers between -100...
Write a program that does the following: Generate an array of 20 random integers between -100 and 100. Compute the average of the elements of the array and find the number of elements which are above the average. For example, if the elements of the array were 5 2 4 1 3 then your program should output The average is 3.0 There are two elements above the average Find the smallest element of the array as well as its index...
Write a matlab code for given task Use your ‘sin’ or ‘cos’ function to generate a...
Write a matlab code for given task Use your ‘sin’ or ‘cos’ function to generate a sinusoid wave having two components as f1 = 3kHz and f2 = 5kHz and then sample it with fs = 10kHz. Calculate its fft with zero frequency component in the middle. Plot it on a properly scaled w-axis. Specify if there is aliasing or not? If there is aliasing specify which component is casing the aliasing
Write a function called randFill that fills the entries of an array with random integers in...
Write a function called randFill that fills the entries of an array with random integers in the range from 10 to 99 (inclusive). (You should use a standard Java method to generate the values. Your solution should use no more than 6 lines of code.) For example, a program that uses the function randFill follows. public class P4 { public static void main(String args[]) { int x[]; x = randFill(5); for (int i = 0; i < 5; i++) System.out.print(x[i]...
Question: include the MATLAB output and commands used with each problem Generate two random 10 ×...
Question: include the MATLAB output and commands used with each problem Generate two random 10 × 10 matrices with numbers between -10 and 10. This can be done with >> A = randi([-10,10],10,10) >> B = randi([-10,10],10,10) 1.     with MATLAB to determi whether A and B are invertible matrices . 2.     If A is invertible, use MATLAB to show that A-1A = I 3.     Determi whether (AB)-1 = B-1A-1 4.     Determin whether (AT)-1 = (A-1)T 5.     Determe whether (A3)-1 = (A-1)3 6.     Determi whether (A +...
CORAL LANGUAGE ONLY Write a program whose inputs are three integers, and whose outputs are the...
CORAL LANGUAGE ONLY Write a program whose inputs are three integers, and whose outputs are the largest of the three values and the smallest of the three values. If the input is 7 15 3, the output is: largest: 15 smallest: 3 Your program should define and call two functions: Function LargestNumber(integer num1, integer num2, integer num3) returns integer largestNum Function SmallestNumber(integer num1, integer num2, integer num3) returns integer smallestNum The function LargestNumber should return the largest number of the...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT