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

1 回表示 (過去 30 日間)
Hans123
Hans123 2024 年 1 月 1 日
コメント済み: Voss 2024 年 1 月 2 日
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 Center および File ExchangeMATLAB についてさらに検索

タグ

製品


リリース

R2022b

Community Treasure Hunt

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

Start Hunting!

Translated by