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

3 次查看(过去 30 天)
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 个评论
Voss
Voss 2024-1-2
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.

请先登录,再进行评论。

回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Line Plots 的更多信息

标签

产品


版本

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by