0

I have loaded some struct (called sensor) into python from my Matlab by doing this

from scipy.io import loadmat
pathToData="C:\Projects\"
fileName = "\sensor.mat"
pathToData = pathToData + fileName
matfile = loadmat(pathToData, squeeze_me=True, struct_as_record=False)
sensor = matfile['sensor']

I can read the data properly but now I would like to write into it some results from python. THe struct has already the field gDist, but I cannot write onto them, why is that?

vmag_in = sensor.vmag_mv[0:sampleN]
vphs_in = sensor.vphs_mv[0:sampleN]
k = 0
for v_mag,v_phs in zip(vmag_in,vphs_in):
    gDist= functionA(v_mag, v_phs,sensor.content[k])

    sensor.gDist[k] = gDist # <-This seems not working?

    # Iterate counter
    k = k +1     
ndarkness
  • 1,011
  • 2
  • 16
  • 36
  • Does [this link](https://stackoverflow.com/a/52466911/1534017) help? – Cleb Aug 15 '19 at 12:31
  • Can you elaborate on what "not working" means? For us it is also impossible to reproduce the error, how does `sensor` look like? What is `functionA` doing etc... Please provide more details, otherwise we cannot help. – Cleb Aug 15 '19 at 12:33
  • I can load a simple `struct` as you do and modify field values. So without further information on your error, we can't help you. – hpaulj Aug 15 '19 at 16:55

1 Answers1

0

matlab struct array start from 1 ther for the Iterate counter k = k +1 most be in the first for loop line