Array after nmz function to create a bar graph

13 ビュー (過去 30 日間)
Jenna Ceraso
Jenna Ceraso 2022 年 4 月 4 日
コメント済み: VBBV 2022 年 4 月 4 日
Hello. I have a csv file with different numbers representing different behaviors. Right now, the code successfully counts how many times a value appears in the csv file (i.e. How many indexes are of the value 5, etc.?). Next, I need to make a bar graph with these values. My array function is not working (maybe because nnz needs to be converted to a different variable type?). Code here:
A=csvread('test.csv'); %csv file with random integers 1-5
quiescence = nnz(A==1);
walking = nnz(A==2);
eating = nnz(A==3);
climbing = nnz(A==4);
mating = nnz(A==5);
figure; % Create new figure
array=(quiescence, walking, eating, climbing, mating); %this is the line that is causing my error
dataLabels={'quiescence'; 'walking'; 'eating'; 'climbing'; 'mating'};
hbar = bar(data); % Create bar plot
set(gca,'yticklabel',dataLabels)
File: behaviorSum2.m Line: 11 Column: 18
Invalid expression. When calling a function or indexing a variable, use parentheses. Otherwise, check for mismatched
delimiters.
Assuming a data type needs to be converted, since the delimiters look fine? Thanks!

採用された回答

VBBV
VBBV 2022 年 4 月 4 日
編集済み: VBBV 2022 年 4 月 4 日
array=[quiescence; walking; eating; climbin; mating] % use []
  2 件のコメント
Jenna Ceraso
Jenna Ceraso 2022 年 4 月 4 日
Thank you so much!!
VBBV
VBBV 2022 年 4 月 4 日
if it solved the problem, please accept the answer , thanks :)

サインインしてコメントする。

その他の回答 (0 件)

カテゴリ

Help Center および File ExchangeNetworks についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by