Specifying a sample of data from a table

1 Ansicht (letzte 30 Tage)
g_co
g_co am 13 Okt. 2021
Bearbeitet: Dave B am 13 Okt. 2021
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.

Antworten (1)

Dave B
Dave B am 13 Okt. 2021
Bearbeitet: Dave B am 13 Okt. 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
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

Kategorien

Mehr zu Tables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by