Specifying a sample of data from a table

1 次查看(过去 30 天)
编辑: Dave B ,2021-10-13
I am trying to find how to specify a section of data to be analysed by a certain function. What is the method of doing so?
I'm currently using the circ_r and circ_std function kindly created by Philipp Berens available at http://www.jstatsoft.org/v31/i10, in order to analyse wind direction data.

回答(1 个)

Dave B
Dave B 2021-10-13
编辑:Dave B 2021-10-13
This sounds like a pretty broad topic, how to index things in MATLAB.
You might be interested in this documentation page about indexing: https://www.mathworks.com/help/matlab/math/array-indexing.html
Here's some example code that calls circ_r with various subsets of an arbitrary theta
theta = [pi/3 pi/2 pi/5 2*pi];
circ_r(theta) % all theta
circ_r(theta(1:3)) % first three theta
circ_r(theta([1 4])) % first and fourth theta
circ_r(theta(end-1:end)) % last two theta
circ_r(theta(theta<pi/2)) % first and third theta
circ_r(theta(1:2:end)); % first and third theta
a = [1 2 3 4];
circ_r(theta(a>2)) % last two theta
circ_r(thata(a==1 | a>2)) % first, third, and fourth theta
If your data are in a table things are pretty similar:
% etc

Community Treasure Hunt

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

Start Hunting!

Translated by