Loop to generate Histogram
Ältere Kommentare anzeigen
I have two random numbers and add them together.
a_x = (-2.5 + (2.5+2.5)*rand(1,1));
a = 5*1e-9;
b = 0;
a_z = a.*randn(1,1) + b;
A = a_x + a_z
Step 1:
Now I want to do this 100 times and create the histogram of all the results of A.
Step2:
Then I want to sort the values in ascending order.
Can someone please explain me how to do the two steps?
5 Kommentare
Ankit
am 31 Jan. 2022
but in above problem, you forgot to mentioned about a_y and Z1
Step 1: using for loop
Step 2: using sort command. Sort array elements - MATLAB sort - MathWorks Deutschland
Lucas Kellermann
am 31 Jan. 2022
Arif Hoq
am 31 Jan. 2022
What is Z1?
Lucas Kellermann
am 31 Jan. 2022
Step 1: using for loop:
read more about for loop for loop to repeat specified number of times - MATLAB for - MathWorks Deutschland
a = 5*1e-9;
b = 0;
a_x = zeros(100,1);
a_z = zeros(100,1);
A = zeros(100,1);
for i= 1:100
a_x(i) = (-2.5 + (2.5+2.5)*rand(1,1));
a_z(i) = a.*randn(1,1) + b;
A(i) = a_x(i) + a_z(i);
end
histogram(A)
Step 2: try by yourself :)
Akzeptierte Antwort
Weitere Antworten (0)
Kategorien
Mehr zu Data Distribution Plots finden Sie in Hilfe-Center und File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!

