Dialog box for grouping samples

5 次查看(过去 30 天)
Hi all,
I tried to look for this topic on the web but I'm not able to properly formulate the question.
My problem is the following. I have a huge database in excel with a lot of column. After import it and do some adjustments I have some columns that are common for all my samples (e.g. temperature, atmospheric pressure, bla bla) and then the specific results for each samples (they can be from 10 to 1000: it's not relevant the number). Among these samples there are some of them that are blank samples but each of them related to only a small group. For example, the first blank is related to a group of 10 samples, the second blank is related to 12 samples,....
Since I want that the script ask to me which are the blanks and which samples related to a specific blank, I'd like to create a dialog box that can "link" a blank to a group of samples...
Here what I've written up to know.
"Data" is my database in a table-format (for example: 4519x136 table)
"SampNames" is the name list that contains the blanks and the samples names (which are all in one table)
"SAMPNAME" is the same name list but I substitute some letter in order to obtain some nicer labels at the end of the script (for some graphs).
"indSampBlank" is a variable which contains only the column number of the blanks.
%% Blank reference choice
[indx,tf] = listdlg('PromptString',{'Mandatory: select the reference Blank'},'ListString',SampNames); %choose reference blank
if isempty(indx) %in case no choice was done, the reference blank is the last sample blank
msgbox(strcat(['Reference blank chosen by default:',SampNames(indSampBlank(end))]));
RefBlankCol=indSampBlank(end);
else
for i=1:size(indx,2)
RefBlankCol(1,i)=find(contains(Data.Properties.VariableNames,string(SAMPNAME(indx(1,i)))) & contains(Data.Properties.VariableNames,'Area'));
end
end
What these lines do is this:
As you can see, I can just select the blanks (even more than one) but I cannot assign for example Blank-DA4809-15 to samples from DA4809 to DA4815 only and to assign Blank-DA4816-22 to samples from DA4816 to DA4822.
Am I clear?
Do you have any suggestions?
Thanks in advance.

采纳的回答

Divyanshu
Divyanshu 2023-3-24
Instead of using single dialog box you can use two uilistboxes.
  • One uilistbox should display the list of blanks in the tableSampNames.
  • Other uilistbox should be made multiselect and it should display the list of samples in the table ‘SampNames’.
You can refer to the below script which enable to select one blank and multiple samples with the help of uilistboxes. ‘Blanks’ hold the list of blanks and Samples hold the list of samples.
function selectlistbox
fig = uifigure('Position',[100 100 350 275]);
% Create text area
txt1 = uitextarea(fig,'Position',[100 90 100 22],'Value','');
txt2 = uitextarea(fig,'Position',[220 70 100 40]);
% Create list box
Blanks = uilistbox(fig,...
'Position',[100 120 100 78],...
'Items',{'First','Second','Third'},...
'ValueChangedFcn', @updateEditField);
% ValueChangedFcn callback
function updateEditField(src,event)
txt1.Value = src.Value;
end
Samples = uilistbox(fig,...
'Position',[220 120 100 78],...
'Items',{'S1','S2','S3'},...
'Multiselect','on',...
'ValueChangedFcn', @updateSelectedSampleField);
function updateSelectedSampleField(src,event)
txt2.Value = src.Value;
end
end
Now once you have the selected items from both the list you can assign or perform any other action over them.
Refer the following documentation to get better understanding of uilistbox:

更多回答(0 个)

类别

Help CenterFile Exchange 中查找有关 Develop uifigure-Based Apps 的更多信息

产品


版本

R2022a

Community Treasure Hunt

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

Start Hunting!

Translated by