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

 채택된 답변

Jos (10584)
Jos (10584) 2016년 2월 24일

0 개 추천

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)

추가 답변 (0개)

카테고리

도움말 센터File Exchange에서 Data Type Identification에 대해 자세히 알아보기

태그

질문:

2016년 2월 24일

편집:

2016년 2월 24일

Community Treasure Hunt

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

Start Hunting!

Translated by