Write a Matlab script to generate an array
Course:- MATLAB Programming
Reference No.:- EM132369444

Assignment Help
Expertsmind Rated 4.9 / 5 based on 47215 reviews.
Review Site
Assignment Help >> MATLAB Programming

Assignment -

1. Write a Matlab script to generate an array of 100 random samples between -5 and 5. The script should then copy the samples one by one to a new array, and check if they are within a limit range set between variables min and max, set at -2 and 2, respectively. If a sample is outside the range, it should be set to the limit value. Using the script, plot both arrays on the same figure.

2. Write a Matlab script to generate the plots of y = 5x2, where x is within [0, 10].

  • The step size of x in the first plot is 0.2.
  • The step size of x in the second plot is 0.5.
  • The step size of x in the third plot is 1.
  • The step size of x in the fourth plot is 2.

In the script, use the subplot command to display four plots on one figure.

  • Plot 1 should choose the red color.
  • Plot 2 should choose the blue color.
  • Plot 3 should choose the green color.
  • Plot 4 should choose the black color.
  • The point format in each plot should choose '+';.
  • The connection between dots should be dashed '--'.

3. Write a Matlab function that will accept an array of numbers. The function should sort the values from lowest to highest using two loops. Do not use the sort() or similar pre-made Matlab functions.

(Hint: one way to do this is a bubble sort algorithm. Use a "for" loop that repeats n-1 times, where n is the number of elements in the array. Within that loop, use another "for" loop that indexes through each element of the array (from 1 to n-1), compares it with the next highest element, and switches them if the first number is larger than the second.)

Put your comment

Ask Question & Get Answers from Experts
Browse some more (MATLAB Programming) Materials
If b=3, a=6 how many loops would the given program do? what will be the out put for z(4)? what would be size (in rows and columns) for variables z, i and b?
Perform a principal component analysis on the dataset you have generated - what is the total variability in the dataset and what is the percent of the total variability explai
Discuss the limitations of a linear classifier. What are some ways in which these limitations could be overcome - Discuss the limitations of the naive nearest neighbor algorit
Compute the time dependent Fourier transform of the complex digital signal. Plot it as a 2- dimensional function of true analog frequency (Hz) on the y-axis and time (sec) on
Took the output of segmentation as input and then apply svm and baysain for classification. I want exect(in 3*3 matrix) output as that results from svm and Bayesian both sid
Create a script file for conversion of temperatures. Use the input function or menu function to allow the user to enter temperature scale of Fahrenheit, Celsius, Kelvin, or Ra
Write a MATLAB code to find the stator core dimension D and L and number of slots and winding turns for a delta connected squirrel cage induction motor then start the specif
Write a MATLAB function that would simulate rolling a biased ("lucky") die N times; i.e., the function must return face values of N rolls of a biased die (N is a function in