How do i print all of the indexes of c?

1 次查看(过去 30 天)
%% 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.

回答(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