Question: Graphical Data Representation - Histogram Normal Distribution To create a histogram from a simulation of a normal distribution, the randn function is needed. The format

Graphical Data Representation- Histogram Normal Distribution
To create a histogram from a simulation of a normal distribution, the randn function is needed. The
format is as follows:
Variable_name = mu+sigma*randn([array])
ESET 329 Six Sigma and Applied Statistics
where mu is the mean and sigma is the standard deviation. This variable will act as your frequency axis,
or as vector Y, for your histogram. The function for plotting the histogram on MATLAB is hist(Y,X). X, in
this case, will be the individual range of your frequencies. This is defined as a vector with constant
spacing.
1. With this in mind, plot a histogram with the following constraints:
A 50 x 1 randomly generated array with a mean of 1(mu) and a standard deviation of 2.5
(sigma), and a bin width array that increments by one from -8 to 8.
Save your .m file with your initials as Lab2_MATLAB_Initials and save the histogram figure as a
separate image file. Does this graph look symmetrically bell-shaped, or normal?
2. Now change the number 50 to 5000 and repeat the same steps. Compare the histogram with the
one you get the step 1. Does this graph look symmetrically bell-shaped, or normal?
Simulink-simulation for dynamic systems such as motors
1. Run a model in Simulink
Copy the Simulink model DCPMmotorNonParametrized from eCampus to the Current
Folder window in MATLAB. In the Current Folder double click the file
DCPMmotorNonParametrized. Exam the values for parameters such as Jinv, Vbatt, and
Linv by double clicking the corresponding blocks. For example, double click on the Jinv
gain block, you will find the Gain is defined as 1/0.042.
Click the green Run button, then double click the Scope and Scope1 blocks to look at the
motor current and motor speed.
Try to zoom in/out and change the scale X/Y axes limits
ESET 329 Six Sigma and Applied Statistics
Fig. 1. Motor speed trace
2. Run a model from an .m file
Copy the file MfileforSimulink.m from eCampus to the Current Folder of MATLAB, then double
click it in the Current Folder. You should see the m file open with lines of codes. Read the code
and try to understand what each line does. Use help command_name in the command window
to read the documentation (For example, help sim, help plot, help figure).
Explore the Simulink model by double clicking DCPMmotor in the Current Folder and then
double clicking each block in it. Do you find the value for the parameter in each block?
Now run the mfile MfileforSimulink.m. You should see plots.
Set all the parameters, such as Linv, Jinv, etc., in these two methods to be the same, then you
have the same result from these two methods. The mfile method allows the user to easily
change parameters and rerun the model. For example, you can add code to the m file so that a
for loop is created to change parameter values.
3. Use the mfile to plot the steady-state speed (the limit of the speed when time goes to infinity) as
a function of the voltage applied (Vbatt).
First define a voltage vector: Vbatt_i=[6:0.5:14];
Then create a for loop:
for i=1:N,
Vbatt=Vbatt_i(1,i);
[T,X,Y]=sim('DCPMmotor.mdl',[0:0.02:3]);
Vbatt_j(i,1)= Vbatt;
Speed1(i,1)=max (Y(:,1));
end
figure(3)
plot(Vbatt_j, Speed1)
grid on
Test your code with N =4. If your code works as you expected, insert the following before the for
loop:
N=size(Vbatt_i);
N=N(2);
Change the values of the second and third parameters in
sim('DCPMmotor.mdl',[0:0.02:3])
(Try [0:0.001:3],[0:0.1:3],[0:0.01:0.1], and other values. Discuss what you observed in the two
scopes.)

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!