Use the code below for a new script in the matlab editor window. The code create
ID: 3786523 • Letter: U
Question
Use the code below for a new script in the matlab editor window. The code creates some fake data involving a fictitious experiment where 1000 individuals are tested under no caffeine (scores1) vs. lots of caffeine (scores2). Use the data in the vectors scores1 and scores2 for your plot. Add code to create a figure as shown below that shows two histograms of the data. Pay close attention to the bins used in the histogram and the axis limits. The two panels should be in one Matlab figure. Read up on the "hist" command using Matlab's help. In the answer box, paste the matlab code (multiple lines are fine) that you used to recreate this figure. rng( 1 ); % Set the seed of the random number generator scores1 = randn( 1000,1 )*10 + 60; % Create fake data of 1000 values in condition 1 scores2 = [ randn( 500,1 )*10+30; randn( 500,1 )*5+70 ]; % create fake data of 1000 values for condition 2
300 200 100 200 150 100 50 Distribution of Test Scores: Normal State 60 80 20 40 Distribution of Test Scores: Extreme Caffeine Intake 20 60 80 40 Score 100 100Explanation / Answer
hist(ax,x,xbin) plots into the axes specified by ax instead of into the current axes (gca).
scores1=randn( 1000,1 )*10 + 60;% Create fake data of 1000 values in condition 1
scores2=scores2 = [ randn( 500,1 )*10+30; randn( 500,1 )*5+70 ]; % create fake data of 1000 values for condition 2
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.