convert code from a python function to matlab
Show older comments
How to convert the following python code to matlab code?
below I send the code.
Thank you so much
# lambda L;
def J(X):
L=0.5
Xorigin=np.zeros([2,1])
JA=np.mean(np.sum(np.power(X-np.tile(Xorigin,(1,P)),2),axis=0))
JB=0
for i in range(0,P):
for j in range(i+1,P):
JB+=1/np.sum(np.power(X[:,i]-X[:,j],2))
JB=JB/(P*(P-1)/2)
return JA+L*JB
Function:

Accepted Answer
More Answers (1)
Dany
on 18 May 2021
0 votes
Categories
Find more on Call Python from MATLAB in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!