How to assign value to a variable?

3 views (last 30 days)
Iugo on 26 Mar 2021
Commented: Jan on 28 Mar 2021
Hello everyone!
I have a code that allows user to choose the folder of subjects from different groups of data (17 in total, where one contains all the subjects from all groups) to perform a certain analysis. I already used dir function to store all the information from the folder with all the subjects from all groups (name, folder, date, etc) in a variable PasteInfo, as well as a field with the classification labels that define if that subject is diseased ou healthy, as show below.
At some point of my code, I need to extract that classification labels for all the subjects of the selected folder (from one specific group or from the paste with all of them) and save in a .mat file. Plus, how can I accomplish it even if the subjects were randomly selected? For example, the user selects folder "Caltech" and gets the .mat file with those classification labels, or if he selects random subjects from the folder with all of the subjects and gets that .mat file with those classification labels...
Can someone give me a help?
Thank you so much!
Iugo on 27 Mar 2021
Oh sorry @Matt J, with paste I mean folder... so sorry about that

Sign in to comment.

Answers (1)

Jan on 27 Mar 2021
How do you want to select the subjects randomly? How does the users select a folder?
The current explantions are too vague for a reliable suggestion of code. But a bold guess:
FolderList = {PasteInfo.folder};
[~, FolderName] = fileparts(FolderList);
MatchFolder = strcmp(FolderList, 'Caltech');
Labels = {PasteInfo(MatchFolder).Labels};
And now?
Jan on 28 Mar 2021
Sorry, I cannot follow you. I still do not know, how a user can select a folder. What are the "classification labels" of "that folders subject"? What is a subject? What are group folders?
What is the difference between the output of my suggested code and your need?

Sign in to comment.

Community Treasure Hunt

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

Start Hunting!