How to code for Barchart and mean in matlab
1 view (last 30 days)
Show older comments
Siddharth Satishchandran
on 19 Jun 2021
Commented: Siddharth Satishchandran
on 20 Jun 2021
I am using Matlab for the first time. I have used R before but Im new to Matlab. The new lab Im in wants me to use more Matlab in place of R programming for the next project. Im working on primate vocalizations. We have data that we have collected over months for a number of individuals. Im tryin to create a script that calculates mean call rate for just the first three animals in the dataset (no. of vocalizations/minute) and i'm trying to create a bar chart showing the call rate of each animal. It would be great If I could get some help so I can get started on working with the larger datasets for the lab. I have attched the the extracted dataset that I am using as a sample to make the barchart and the calculate the mean. I think for the mean calculation, I have to use the audio stop and start columns.
0 Comments
Accepted Answer
Sulaymon Eshkabilov
on 19 Jun 2021
Edited: Sulaymon Eshkabilov
on 19 Jun 2021
Simply to use bar():
DD = readtable('Data extracted- Lab.xls');
DD = readtable('Data extracted- Lab.xls');
Mean_A =DD.AudioStartTime;
Mean_V =DD.VideoStart;
figure
bar(DD.AudioStartTime)
figure
bar(DD.VideoStart)
...
2 Comments
More Answers (6)
Siddharth Satishchandran
on 19 Jun 2021
Edited: Image Analyst
on 19 Jun 2021
2 Comments
Image Analyst
on 19 Jun 2021
The file you uploaded had only 3 lines of data - not enough to get averages for all those call types and categories. Please upload an actual file with lots of data in it.
Sulaymon Eshkabilov
on 19 Jun 2021
Error in your command syntax:
load('/Users/ameliachang/Downloads/LabelTable.mat') % one ) has to be removed.
Sulaymon Eshkabilov
on 19 Jun 2021
load('C:\Users\siddharthsatish\Downloads\LabelTable.mat') % Fix directory: C:\ or D:\
2 Comments
Sulaymon Eshkabilov
on 19 Jun 2021
Ok. Well Mac has a different syntax for directory specs.
In that case, you can change the directory and then load the data file. Try this:
cd ~/ameliachang/'Downloads'
You may also try using "Finder" to find the folder, right-click on it, and then click "Get Info".
3 Comments
Sulaymon Eshkabilov
on 19 Jun 2021
cd ~/home/mluser/siddharthsatish/'Downloads' % Watch where apostrophe signs ' ' are placed
4 Comments
Sulaymon Eshkabilov
on 20 Jun 2021
Just put your *.mat file into your MATLAB directory, then you can load all your data with one simple command, e.g.:
load('LabelTable.mat')
See Also
Categories
Find more on Animation in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!