How do i print all of the indexes of c?

1 visualización (últimos 30 días)
Serena Simpson
Serena Simpson el 26 de Sept. de 2020
Comentada: Walter Roberson el 26 de Sept. de 2020
%% 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 comentario
Walter Roberson
Walter Roberson el 26 de Sept. de 2020
That last line looks okay; just add a line to output a newline afterwards.

Iniciar sesión para comentar.

Respuestas (0)

Categorías

Más información sobre Performance and Memory en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

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

Start Hunting!

Translated by