Call a Python function inside a MATLAB loop
In a Matlab script, is there a way to call a Python function, in loop for, in such a way that at every iteration the inputs of the Python function are different?
This is my case, where the arrays "a" and "b" are always different, and they return, obviously, different output:
% My Python function
import numpy as np
from scipy import stats
a = [7, 42, 61, 81, 115, 137, 80, 100, 121, 140, 127, 110, 81, 39, 59, 45, 38, 32, 29, 27, 35, 25, 22, 20, 19, 14, 12, 9, 8, 6, 3, 2, 2, 0, 0, 1, 0, 1, 0, 0];
b = a;
rng = np.random.default_rng()
method = stats.PermutationMethod(n_resamples=9999, random_state=rng)
res = stats.anderson_ksamp([a,b], method=method)
print(res.statistic)
print(res.critical_values)
print(res.pvalue)
To add more details, I would like to have something like this in Matlab:
% Call a Python function inside a MATLAB loop
for i = 1 : 10
a = randi([1 100],1,50);
b = randi([1 100],1,50);
out = call_python_function_here;
endIn a Matlab script, is there a way to call a Python function, in loop for, in such a way that at every iteration the inputs of the Python function are different?
This is my case, where the arrays "a" and "b" are always different, and they return, obviously, different output:
% My Python function
import numpy as np
from scipy import stats
a = [7, 42, 61, 81, 115, 137, 80, 100, 121, 140, 127, 110, 81, 39, 59, 45, 38, 32, 29, 27, 35, 25, 22, 20, 19, 14, 12, 9, 8, 6, 3, 2, 2, 0, 0, 1, 0, 1, 0, 0];
b = a;
rng = np.random.default_rng()
method = stats.PermutationMethod(n_resamples=9999, random_state=rng)
res = stats.anderson_ksamp([a,b], method=method)
print(res.statistic)
print(res.critical_values)
print(res.pvalue)
To add more details, I would like to have something like this in Matlab:
% Call a Python function inside a MATLAB loop
for i = 1 : 10
a = randi([1 100],1,50);
b = randi([1 100],1,50);
out = call_python_function_here;
end In a Matlab script, is there a way to call a Python function, in loop for, in such a way that at every iteration the inputs of the Python function are different?
This is my case, where the arrays "a" and "b" are always different, and they return, obviously, different output:
% My Python function
import numpy as np
from scipy import stats
a = [7, 42, 61, 81, 115, 137, 80, 100, 121, 140, 127, 110, 81, 39, 59, 45, 38, 32, 29, 27, 35, 25, 22, 20, 19, 14, 12, 9, 8, 6, 3, 2, 2, 0, 0, 1, 0, 1, 0, 0];
b = a;
rng = np.random.default_rng()
method = stats.PermutationMethod(n_resamples=9999, random_state=rng)
res = stats.anderson_ksamp([a,b], method=method)
print(res.statistic)
print(res.critical_values)
print(res.pvalue)
To add more details, I would like to have something like this in Matlab:
% Call a Python function inside a MATLAB loop
for i = 1 : 10
a = randi([1 100],1,50);
b = randi([1 100],1,50);
out = call_python_function_here;
end call python MATLAB Answers — New Questions