How to assign value to a variable?

3 次查看(过去 30 天)
Iugo
Iugo 2021-3-26
评论: Jan 2021-3-28
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 个评论
Matt J
Matt J 2021-3-27
编辑:Matt J 2021-3-27
You're using the word "paste" in a way I don't recognize. Is that data science jargon of some kind?
Iugo
Iugo 2021-3-27
Oh sorry @Matt J, with paste I mean folder... so sorry about that

请先登录,再进行评论。

回答(1 个)

Jan
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 个评论
Iugo
Iugo 2021-3-27
编辑:Iugo 2021-3-27
I will reformulate @Jan.
I have a struct variable called PasteInfo, that contains information such as name, folder, date, etc, about the subjects from the folder selected by the user. I also have a struct variable called PasteInfoLabels which has the same information (image below), plus the classification labels (0's and 1's), but for all the data from all the group folders.
My goal is to, no matter what folder is selected by the user, the code being able to retrieve a column vector .mat file with the respective classification labels of that folder subjects...
Do you have any ideas of how can I accomplish this?
Thank you so much for your help!
Jan
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!

Translated by