# How do i print all of the indexes of c?

조회 수: 2(최근 30일)
Serena Simpson 2020년 9월 26일
댓글: Walter Roberson 2020년 9월 26일
%% Module 5 Prog 2
%
%This rogram will use a file from canvas to answer a series of questions
%
%ENG 101-04
%Serena Simpson
%September 18
%% Section 1: Initalization of Variables
%this loads the file needed for this project
%% Section 2: Processing
%This is for part a. The variable 'a' creates a logical array of all
%elements greater than 90. The variable 'a1' counts how many 1s are in the
%logical array of 'a'.
a = (nr > 90);
a1 = numel(nr(a));
b = (nr > 70 & nr < 80);
b1 = numel(nr(b));
mean(b1);
c = (nr > 30 & nr < 32);
c1 = numel(nr(c));
index_array = nr(c(1:12));
%% Section 3: Result Output
%The output for array 'a1' and the sum of a
fprintf("Number of elements >90 is %.0f \n", a1)
fprintf("The sum of elements >90 is %.0f \n", sum(nr(a)))
%The output for array 'b1' and the average of b
fprintf("Number of elements >70 and <80 is %.0f \n", b1)
fprintf("The average of all of values in variable b is %.2f \n", mean(nr(b)))
%The output for array 'c1' and the indeces of c
fprintf("Number of elements >30 and <32 is %.0f \n", c1)
fprintf('%d ',index_array) %This is the line where I need to print all of the indeces.
##### 댓글 수: 1표시숨기기 없음
Walter Roberson 2020년 9월 26일
That last line looks okay; just add a line to output a newline afterwards.

댓글을 달려면 로그인하십시오.

### Community Treasure Hunt

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

Start Hunting!

Translated by