How to assign value to a variable?
3 次查看(过去 30 天)
显示 更早的评论
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!
2 个评论
回答(1 个)
Jan
2021-3-27
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?
2 个评论
Jan
2021-3-28
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?
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!