3,456 views [last 30 days]
Hello, I have a matlab code for the quantitative differential phase contrast imaging and the code is very big and complicated as well. But the problem is the institute where I am working does not allow to use matlab and they have python and LabVIEW, so I would like to convert the matlab code to python or someone knows how to run the matlab code in python then it also be very helpful.
I have attached the main code.
Thank you.
Answers [4]
You can use numpy framework which contains matlab libraries.
Seecheat sheet , I faced similar situation as you but raged with the cheat sheet, good luck!
clc[] clear[mstring['all']] close[mstring['all']] # Generating the bit pattern with each bit 20 samples long b = round[rand[1, 30]] pattern = mcat[[]] for k in mslice[1:30]: if b[1, k] == 0: sig = -ones[1, 20] else: sig = ones[1, 20] end
pattern = mcat[[pattern, sig]]
end
subplot[4, 1, 1]
plot[pattern]
axis[mcat[[-1, 600 - 1.5, 1.5]]]
title[mstring['Original Bit Sequence']]
# Generating the pseudo random bit pattern for spreading
d = round[rand[1, 120]]
pn_seq = mcat[[]]
carrier = mcat[[]]
t = mcat[[mslice[0:2 * pi / 4:2 * pi]]]# Creating 5 samples for one cosine
for k in mslice[1:120]:
if d[1, k] == 0:
sig = -ones[1, 5]
else:
sig = ones[1, 5]
end
c = cos[t]
carrier = mcat[[carrier, c]]
pn_seq = mcat[[pn_seq, sig]]
end # Spreading of sequence spreaded_sig = patternelmul pn_seq subplot[4, 1, 2] plot[spreaded_sig] axis[mcat[[-1, 600 - 1.5, 1.5]]] title[mstring['Spreaded signal']] # BPSK Modulation of the spreaded signal bpsk_sig = spreaded_sigelmul carrier# Modulating the signal subplot[4, 1, 3] plot[bpsk_sig] axis[mcat[[-1, 600 - 1.5, 1.5]]] title[mstring['BPSK Modulated Signal']] #Plotting the FFT of DSSS signal y = abs[fft[xcorr[bpsk_sig]]] subplot[4, 1, 4] plot[y / max[y]] xlabel[mstring['Frequency']] ylabel[mstring['PSD']] #Demodulation and Despreading of Received Signal figure[] rxsig = bpsk_sigelmul carrier demod_sig = mcat[[]] for i in mslice[1:600]: if rxsig[i] >= 0: rxs = 1 else: rxs = -1 end demod_sig = mcat[[demod_sig, rxs]] end subplot[3, 1, 1] plot[demod_sig] axis[mcat[[-1, 600 - 1.5, 1.5]]] title[mstring['Demodulated Signal']] despread_sig = demod_sigelmul pn_seq subplot[3, 1, 2] plot[despread_sig] axis[mcat[[-1, 600 - 1.5, 1.5]]] title[mstring['Despreaded data']] #Power Spectrum of Despreaded data z = 0.5 + 0.5 * despread_sig y = abs[fft[xcorr[z]]] subplot[3, 1, 3] plot[y / max[y]] axis[mcat[[0, 500, 0, 1.5]]] xlabel[mstring['Frequency']] ylabel[mstring['PSD']]
A=imread['C:\Users\Administrator\Desktop\Mango_Database\RIPE\R22.jpg'];
figure;imshow[A];impixelinfo;
if[R>180&&G150&&B