
How do structures work?
7 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
How do structures work? I've been trying a smoewhat big struct file but the workspace cannot seem to be able to find the values of the structure (the values of the fields are missing). Here is the code. Please help me I do not know what to do.

Default_GP = struct ( ...%
...% -- Connection Properties --
...%
'Platform', "B200", ...
'SerialNum', "321E19C", ...
...%
...% -- Configuration Propreties --
...%
...% Frequency
...%
'CenterFrequency', 101e6, ...
'FrequencyCorrection', 0, ... //LO offset
'FrequencyStepsString' ,{{'1 Hz','10 Hz','100 Hz','1 kHz','10 kHz','100 kHz','1 MHz','10 MHz','100 MHz'}}, ...
'AllFrequencySteps',[1,10,100,1e3,10e3,100e3,1e6,10e6,100e6],...
'FrequencyStep',100e3,...
...%
...% Reciever Gain
...%
'RecieverGain', 0,... % 76 dB - max reciver gain
...
...
'AllPPSSources', {{"Internal", "External", "GPSDO"}},...
'PPSSource', "Internal",...
'AllClockSources', {{"Internal", "External", "GPSDO"}},...
'ClockSource', "Internal",...
...%
...% Output
...%
'AllSampleRates', {},... % range of sample rates 5MHz - 61.44MHz
'SampleRateSteps', {{'0.1 MHz', '1 MHz','10 MHz'}},...
'AllSampleRateSteps', [0.1e6, 1e6, 10e6],...
'SampleRate', 32e6,... % Master Clock Rate
...
'TransportDataTypeStrings', {{"int16", "int8"}},...
'TransportDataType', "int16",...
'OutputDataTypeString', {{"int16", "int18", "single", "double"}},...
'OutputDataType', "double",...
...
'AllSamplesPerFrameString',{{'4096','8192','16384','32768','65536','131072','262144'}},...
'AllSamplesPerFrame',[4096,8192,16384,32768,65536,131072,262144],...
'SamplesPerFrame',131072,...
...
'EnableBurstMode',false,... % Ensure a set of frames without overrun of USRP B200 output
'NumFramesInBurst',10,... % Number of frames in contiguous burstof USRP B200 output
...%
...% Baseband Decimation
...%
'AllDecimationFactorsRanges', {{'[1, 128]', '[128, 256]', '[256-512]'}},...
'DecimationMultiplesOf', [1, 2, 4],...
'DecimationFactor', 1); % to be added
1 Commento
Stephen23
il 30 Apr 2024
Modificato: Stephen23
il 30 Apr 2024
"the values of the fields are missing"
Because your entire structure is empty it cannot contain any data:

"Please help me I do not know what to do"
You probably want a scalar structure. In that case note very carefully what the documentation explains about cell arrays which are input to the STRUCT command. If you want a field to contain an empty cell array, then you will need to nest it inside a scalar cell array:
S = struct('x',{{}},'y',pi)
Risposte (1)
Voss
il 30 Apr 2024
Modificato: Voss
il 30 Apr 2024
To create a scalar (as opposed to a 0x0) structure array, this
'AllSampleRates', {},...
needs to be
'AllSampleRates', {{}},...
Explanation: struct creates a structure array, the size of which is determined by the value arguments. In particular (from the documentation):
- If value is an empty cell array {}, then s is an empty (0-by-0) structure.
- If value is a nonscalar cell array, then s is a structure array with the same dimensions as value.
- If value is not a cell array, or if value is a scalar cell array, then s is a scalar structure.
Interestingly, all the other cell array value arguments in your code are already scalars; you only missed making the 0-by-0 cell array {} into the scalar cell array {{}} for AllSampleRates.
Default_GP = struct ( ...%
...% -- Connection Properties --
...%
'Platform', "B200", ...
'SerialNum', "321E19C", ...
...%
...% -- Configuration Propreties --
...%
...% Frequency
...%
'CenterFrequency', 101e6, ...
'FrequencyCorrection', 0, ... //LO offset
'FrequencyStepsString' ,{{'1 Hz','10 Hz','100 Hz','1 kHz','10 kHz','100 kHz','1 MHz','10 MHz','100 MHz'}}, ...
'AllFrequencySteps',[1,10,100,1e3,10e3,100e3,1e6,10e6,100e6],...
'FrequencyStep',100e3,...
...%
...% Reciever Gain
...%
'RecieverGain', 0,... % 76 dB - max reciver gain
...
...
'AllPPSSources', {{"Internal", "External", "GPSDO"}},...
'PPSSource', "Internal",...
'AllClockSources', {{"Internal", "External", "GPSDO"}},...
'ClockSource', "Internal",...
...%
...% Output
...%
'AllSampleRates', {{}},... % range of sample rates 5MHz - 61.44MHz
'SampleRateSteps', {{'0.1 MHz', '1 MHz','10 MHz'}},...
'AllSampleRateSteps', [0.1e6, 1e6, 10e6],...
'SampleRate', 32e6,... % Master Clock Rate
...
'TransportDataTypeStrings', {{"int16", "int8"}},...
'TransportDataType', "int16",...
'OutputDataTypeString', {{"int16", "int18", "single", "double"}},...
'OutputDataType', "double",...
...
'AllSamplesPerFrameString',{{'4096','8192','16384','32768','65536','131072','262144'}},...
'AllSamplesPerFrame',[4096,8192,16384,32768,65536,131072,262144],...
'SamplesPerFrame',131072,...
...
'EnableBurstMode',false,... % Ensure a set of frames without overrun of USRP B200 output
'NumFramesInBurst',10,... % Number of frames in contiguous burstof USRP B200 output
...%
...% Baseband Decimation
...%
'AllDecimationFactorsRanges', {{'[1, 128]', '[128, 256]', '[256-512]'}},...
'DecimationMultiplesOf', [1, 2, 4],...
'DecimationFactor', 1); % to be added
Default_GP
0 Commenti
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!