How do i print all of the indexes of c?

조회 수: 1 (최근 30일)
Serena Simpson
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
load("m05.mat")
%% 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
Walter Roberson 2020년 9월 26일
That last line looks okay; just add a line to output a newline afterwards.

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

답변 (0개)

카테고리

Help CenterFile Exchange에서 Performance and Memory에 대해 자세히 알아보기

태그

Community Treasure Hunt

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

Start Hunting!

Translated by