1 view (last 30 days)

Show older comments

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.

Dave B
on 13 Oct 2021

Edited: Dave B
on 13 Oct 2021

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

Or maybe this article about indexing in MATLAB: https://www.mathworks.com/company/newsletters/articles/matrix-indexing-in-matlab.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:

t=table(theta',a');

circ_r(t.theta);

circ_r(t.theta(1:3));

circ_r(t.theta(t.a>2));

% etc

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

Start Hunting!