Below is a code that I am working on. For line 9 I need help coming up with what to put in the fprintf statement to fill in the '....' spaces. My instructions are to "use the size command in an fprintf command to tell the user how many scores are below the lower cutoff." I've tried to read about the fprintf statement, but I still can't seem to come up with the correct code. Any help? Thanks.
dataFromMyExperiment = 5.*randn(100,1)+10;
nbins = 100;
histogram(dataFromMyExperiment, nbins)
StandardDeviation = std(dataFromMyExperiment)
myMean = mean(dataFromMyExperiment)
lowCutoff = myMean - 2*StandardDeviation
highCutoff = myMean + 2*StandardDeviation
extremeLowValuesIndex = find(lowCutoff)
fprintf('................' ,....... );
actualLowValues = dataFromMyExperiment(extremeLowValuesIndex)
for thisLowScore =
fprintf('%6.3f is below the cutoff/n', actualLowValues)
end

 Akzeptierte Antwort

Jos (10584)
Jos (10584) am 24 Feb. 2016

0 Stimmen

First calculate the number you want to print using size or numel (numel(..) equals prod(size(..))
NumScoresBelowCutoff = numel(extremeLowValuesIndex)
Then display it using frintf
fprintf('There are %d values below the cutoff (%.3f)', NumScoresBelowCutoff, lowCutoff)
In this example, the first argument to fprintf specifies the string to display with two placeholders (indicated by the % symbols) that are to be replaced by the values in the following arguments. There are many kind of placeholders, for integers (%d), for floating points (%f). Moreover, these place holders can have additional arguments (here ".3") to indicate how many decimals should be printed, as in
fprintf('Pi ~ %.10f',pi)

Weitere Antworten (0)

Kategorien

Mehr zu Data Type Identification finden Sie in Hilfe-Center und File Exchange

Tags

Gefragt:

am 24 Feb. 2016

Bearbeitet:

am 24 Feb. 2016

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by