I am having problem converting this to Matlab. It either spits out 'char' as the answer or it would say untitled after i have written it in Matlab and fixed all the errors. Help me out.
조회 수: 1 (최근 30일)
이전 댓글 표시
import itertools
class Armstrong:
def __init__(self, inputF, inputDf, outputF, outputDf, FloMin, FloMax):
self.inputF = inputF
self.inputDf = inputDf
self.outputF=outputF
self.outputDf=outputDf
self.FloMin=FloMin
self.FloMax=FloMax
def productOfMultiplexers(self):
return (self.outputDf/float(self.inputDf))
def primeFactors (self):
n=self.productOfMultiplexers()
I={2:0, 3:0, 5:0, 7:0, 11:0}
for i in I.keys():
while n%i==0:
I[i]+=1
n=n/i
return (I)
def MultiplierCombinaitons(self):
I=self.primeFactors ()
Ilist=[i for i in I.keys() for j in range(I[i])]
stuff = Ilist
productList=[]
for L in range(0, len(stuff)+1):
for subset in itertools.combinations(stuff, L):
product=1
for i in subset:
product=i*product
productList.append(product)
return (sorted(set(productList)))
def bestMatch(self):
case1=case.outputF- case.productOfMultiplexers() * case.inputF
case2=-case.outputF +case.productOfMultiplexers() * case.inputF
case3=case.outputF +case.productOfMultiplexers() * case.inputF
for M2 in case.MultiplierCombinaitons():
for c in [case1,case2,case3]:
if c>0 and c/M2 < case.FloMax and c/M2>case.FloMin:
return(M2,c/M2)
댓글 수: 0
답변 (1개)
Dhananjay Kumar
2019년 12월 3일
편집: Dhananjay Kumar
2019년 12월 3일
I suppose this is python code.
For converting this code to matlab code, you should understand the code completely and manually code it in MATLAB.
Instead of converting the code to matlab, you can call it directly from MATLAB.
See this: Call Python function from MATLAB
댓글 수: 0
참고 항목
카테고리
Help Center 및 File Exchange에서 Call Python from MATLAB에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!