Starting with the structure plan specified in the file find_interval.m, create a
ID: 2079417 • Letter: S
Question
Starting with the structure plan specified in the file find_interval.m, create an m-file that uses
logical vectors to find the portion of a set of Gaussian random numbers that fall within a certain interval.
The set of Gaussian numbers are given in the MAT-file interval_data.mat. The m-file should also save and plot
the portion in the interval. Finally, the m-file should also find the index and value of the maximum value in
the original set of numbers and the final set of numbers.
%
% find_interval.m
%
% start
clear all
close all
% load in the set of 1000 Gaussian random numbers from a MAT file
?????
% Plot the set of 1000 Gaussian random numbers
?????
title('1000 Gaussian Random Numbers - Mean of 0 - Std Dev of 1')
% Find the index and the value of the largest number in random_numbers
?????
% First find the subset of the numbers that are less than +1
?????
% Now find the subset of the subset that are greater than -1
?????
% Save the subset in a MAT-file named "subset_random"
?????
% Create a new figure window
figure
% Plot the subset
?????
title('Subset of Gaussian Random Numbers on the Interval -1 to +1')
% Find the index and the value of the largest number in subset
?????
Explanation / Answer
%
% find_interval.m
%
% start
clear all;
close all;
% load in the set of 1000 Gaussian random numbers from a MAT file
load('interval_data.mat');
% Plot the set of 1000 Gaussian random numbers
figure(1);
plot(interval_data);grid;
title('1000 Gaussian Random Numbers - Mean of 0 - Std Dev of 1')
% Find the index and the value of the largest number in random_numbers
[maxnumber,maxnoindex]=max(interval_data);
% First find the subset of the numbers that are less than +1
Subsetless1=interval_data(interval_data<1);
% Now find the subset of the subset that are greater than -1
Subset=Subsetless1(Subsetless1>-1);
% Save the subset in a MAT-file named "subset_random"
save('subset_random','Subset');
% Create a new figure window
figure
% Plot the subset
plot(Subset);grid;
title('Subset of Gaussian Random Numbers on the Interval -1 to +1')
% Find the index and the value of the largest number in subset
[maxnoSubset,maxnoindexSubset]=max(Subset);
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.