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 Center および File ExchangePerformance and Memory についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by