How to assign value to a variable?

조회 수: 6 (최근 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?

댓글을 달려면 로그인하십시오.

카테고리

Help CenterFile Exchange에서 Statistics and Machine Learning Toolbox에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by