I would like to apply an external code with a particualr function (chaos
; https://figshare.com/s/80891dfb34c6ee9c8b34) from a paper by Toker et al. 2020 (https://www.nature.com/articles/s42003-019-0715-9#Sec1) in order to test whether my data are stochastic or chaotic.
I tried loops, for, cellfun
, but none of these work in this case.
When I tried to use the following code:
T = readtable('ibfrq3.csv');
C = table2array(T);
D = num2cell(C, 2);
rowSums = cellfun(@sum, D)
chaos = cellfun(@chaos, D)
I received three errors:
Unable to perform assignment because the size of the left side is 1-by-14 and the size of the right side is
1-by-3.
Error in chaos>surrogate (line 989)
surr(k,:)=unwrap(horzcat(st,parts{randperm(j)},en));
Error in chaos (line 157)
[surr, params] = surrogate(zscore(surr_y), num_surr, 'CPP', 1, 1);
Interestingly, I am able to make the function work, but only for separate rows (by copying them into square brackets and labelling as y e.g. y = [1,2,3,4,5,6,7,8,9,5,6,7,8,8]
).
My desired output is a string (or ideally a column added to my .csv) with chaos
function outputs (one word per row: 'stochastic' or 'chaotic' depending on the result).
My data are available here: https://drive.google.com/file/d/1I2BChrv0iqNr1dcEKTQKxKF7DDl_hF23/view?usp=sharing The .csv consists of allele frequencies over different time periods.
EDIT: Trying
numRows = size(C, 1);
for row = 1:numRows
result(row) = chaos(C(row,:));
end
Yielded similar errors as above.
I also tried to run the code row by row on my data to check which row causes problems using
row1 = C(1,:);
chaos(row1)
for every row. Interestingly, it works perfectly giving the desired output for rows no.1, 3-9, 11-100. Rows no.2 and no.10 are not different from the others and do not contain any special characters or values. I have no clue what's wrong with them.