Creating a Plotting GUI to extra data from nested structure file and plot

1 view (last 30 days)
I have obtained data from a instrument that is in the form of a strucutre file.
The format of the file is similar to the file created using this code:
clc;clear
% Create a sample nested structure
nestedStruct.dev1260.deviceName = 'MyDevice';
nestedStruct.dev1260.deviceID = 1260;
% Adding demodulators as an array of structures
numDemods = 1;
for i = 1:numDemods
% nestedStruct.dev1260.demods(i).demodulatorName = ['Demodulator' num2str(i)];
nestedStruct.dev1260.demods(i).frequency = rand(1,10); % Some frequency value (this is my x-axis)
nestedStruct.dev1260.demods(i).amplitude = rand(1, 10); % Some amplitude values (this is my y-axis)
nestedStruct.dev1260.demods(i).someothergarbage = rand(1,10); % Not really important
end
% Save the nested structure to a .mat file
save('nestedStructureFile.mat', 'nestedStruct');
My goal is to create a GUI that will be able to do the following:
  1. search for the data file
  2. allow the user to click through to which data I want to plot on my x and y axes
  3. plot the data
The plot would look like:
plot(nestedStruct.dev1260.demods.frequency,nestedStruct.dev1260.demods.amplitude)
I have a GUI that is able to do the first step (browse the file in the current directory, which is sufficient), but I am having trouble clicking through the nested strcuture and selecting the data that I need to plotted in my x- and y- axes.
I attached the GUI code.
Any pointers are appreciated.
  1 Comment
Voss
Voss on 2 Jan 2024
How do you envision step 2 would work? That is, what exactly would the GUI do as the user "clicks through" the nested structure? You may consider using a uitree instead of a listbox.

Sign in to comment.

Answers (0)

Categories

Find more on MATLAB in Help Center and File Exchange

Products


Release

R2022b

Community Treasure Hunt

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

Start Hunting!