Info

此问题已关闭。 请重新打开它进行编辑或回答。

I have a table in Matlab with one column - '{"camera"​:{"avg":1,​"exposure"​:1,"gain":​0},"encodi​ng":"utf-8​","fft":{"​carrier":{​"x":1422,"​y":614}},.​. I would like to search and store single values, like 'y': 614 from this data. Is there a way i can do it?

1 次查看(过去 30 天)
This is the data inside one table. Its extracted from a cdf file. I want to store sepcific values from this data for example PieX=999485. Is it possible to do that ?
'{"camera":{"avg":1,"exposure":1,"gain":0},"encoding":"utf-8","fft":{"carrier":{"x":1422,"y":614}},"fluo_clipping":{"magnification":1,"xOffset":0,"yOffset":0},"illuminator":{"aperture":54,"filter":0,"intensity":21,"wavelength":650},"metaVersion":"1.05","objectives":{"AbsZ":4.34451171875,"NA":0.3,"PieX":999485,"PieY":-1337899,"RelZ":-0.05884765625,"branchLength":714603,"fov":{"x":376.3708609271523,"y":376.3708609271523},"lense":1,"magnification":10,"objShutter":true,"opticalMag":4,"refShutter":true,"refractiveIndex":1},"phase_compensation":{"dynamicMode":false,"iterations":0,"polynomial":0,"threshold":0,"thresholdManu":0,"thresholdType":0},"phase_unwrapping":{"blockSize":0,"interpolate":false,"iterations":0,"maskedAlg":false,"maxIterations":0,"maxReziduaConst":0,"method":-1,"phaseError":0,"startPointSelection":0,"startPos":{"x":0,"y":0},"threshold":0,"weighed":false},"statistics":{"averageAmpl":5.567099206654307,"backgroundAVG":2.8538151703993395e-13,"backgroundSTD":9.848588983510147},"temperature":{"box":37.4,"specimen":36.9}} '
  2 个评论
Githin John
Githin John 2020-1-20
I am assuming that you are already using either cdfread or ncread functions for reading the data. Don't those functions allow you to search for and store specific variable values?
Guillaume
Guillaume 2020-1-20
The text you've copied looks like JSON. It's unclear how that relates to a table. Can you attache a mat-file containing whatever variable stores the data.

回答(1 个)

Guillaume
Guillaume 2020-1-20
It's not clear how your data is stored. However, what you show is json encoded which is easily decoded with matlab:
%demo text. It's not clear how it's stored in your case but it doesn't really matter
text = '{"camera":{"avg":1,"exposure":1,"gain":0},"encoding":"utf-8","fft":{"carrier":{"x":1422,"y":614}},"fluo_clipping":{"magnification":1,"xOffset":0,"yOffset":0},"illuminator":{"aperture":54,"filter":0,"intensity":21,"wavelength":650},"metaVersion":"1.05","objectives":{"AbsZ":4.34451171875,"NA":0.3,"PieX":999485,"PieY":-1337899,"RelZ":-0.05884765625,"branchLength":714603,"fov":{"x":376.3708609271523,"y":376.3708609271523},"lense":1,"magnification":10,"objShutter":true,"opticalMag":4,"refShutter":true,"refractiveIndex":1},"phase_compensation":{"dynamicMode":false,"iterations":0,"polynomial":0,"threshold":0,"thresholdManu":0,"thresholdType":0},"phase_unwrapping":{"blockSize":0,"interpolate":false,"iterations":0,"maskedAlg":false,"maxIterations":0,"maxReziduaConst":0,"method":-1,"phaseError":0,"startPointSelection":0,"startPos":{"x":0,"y":0},"threshold":0,"weighed":false},"statistics":{"averageAmpl":5.567099206654307,"backgroundAVG":2.8538151703993395e-13,"backgroundSTD":9.848588983510147},"temperature":{"box":37.4,"specimen":36.9}}'
json = jsondecode(text); %returns a multilevel structure according to the json
pieX = json.objectives.PieX %navigate the json to PieX

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by