이 질문을 팔로우합니다.
- 팔로우하는 게시물 피드에서 업데이트를 확인할 수 있습니다.
- 정보 수신 기본 설정에 따라 이메일을 받을 수 있습니다.
Compare filename to data in table
조회 수: 3 (최근 30일)
이전 댓글 표시
Debbie Oomen
2018년 5월 1일
Hi!
The attached table (datatable) has a first column containing specific ID numbers. These ID numbers belong to matching individual files. For example, the first ID number below 'ID' is 'C01'. This row of data corresponds to a file named 'IDC01sec.csv' that is saved in the same folder. For my GUI, I need MATLAB to match the ID number to the file so that it can use the data in that row for further analysis.
Any help is appreciated!
댓글 수: 12
Ameer Hamza
2018년 5월 1일
What do you mean by "match the ID number to the file"? Do you want to convert 'C01' to 'IDC01sec.csv'?
John BG
2018년 5월 1일
Hi Debbie
Why don't you just embed a link to the file in the same spreadsheet? In Excel highlight word or words to behave as link, ctrl+L, and all that is left is to check it works.
Debbie Oomen
2018년 5월 1일
@Ameer Hamza, no I do not want to convert it. The C01 is the unique part of the filename IDC01sec.csv. Other files have the same ID...sec.csv format but a different ID number. I will explain further: the IDC01sec.csv file contains continuous data from multiple consecutive days, so 24 hours from day 1 to 24 hours from day 10. However, we are not interested in the complete data from those 24 hours, but only data from a specific timeframe. The attached table contains these important specific timeframes from each day that contains the actual necessary data that is needed for further analysis. So it says that C01 on day 1, has important data from 07:00 to 21:00. MATLAB needs to be able to recognize these timestamps and analyze only data between those timestamps from the IDC01sec.csv file.
Debbie Oomen
2018년 5월 1일
@John BG, everything has to be done in MATLAB. It is a GUI and is supposed to be used for data analysis so I don't believe that this will work
Ameer Hamza
2018년 5월 2일
You cannot refer to specific parts of a file directly. You will need to read the entire file and then search for the specific data you want. If you are worried about the overhead of reading and processing file then it is better to generate .mat files from all the csv files. MATLAB can quickly read these files and they are also ready to process.
Jan
2018년 5월 2일
@Debbie: You do have the string 'C01' already and want to import the contents of the file 'IDC01sec.csv'. This sounds like all you have to do is:
str = 'C01'; % Coming from anywhere in your code
FileName = sprintf('ID%ssec.csv');
Data = csvread(FileName);
Now these data must be inserted where you need it.
Currently this advice is very vague, because the description of your problem is also. Can you post the current code and explain more exactly, what the problem is?
Debbie Oomen
2018년 5월 2일
@Jan, I have attached the GUI and the code. If you open the GUI, you see three options for analyzing file. Now, these files all have the same format: 'ID...sec.csv'. Belonging to these files is a so-called diaryfile that keeps track of important timestamps for all files in 1 spreadsheet (see attachment Diaryrecord). In the first column of the spreadsheet are the ID numbers that match the filenames. I need MATLAB to recognize the specific row with timestamps that matches the filename. These timestamps are then used to analyze only that part of the ID0215.csv file
Jan
2018년 5월 2일
@Debbie: The descriptions are not clear, if one does not know already, what you exactly mean:
I need MATLAB to recognize the specific row with timestamps
that matches the filename
"Recognize" can mean a variety of things.
...used to analyze only that part of the ID0215.csv file
What does this mean?
Debbie Oomen
2018년 5월 2일
Okay, so for example:
filename: ID0215sec.csv contains 7 days of continuous data from the subject with that ID The Diaryrecord is a file with a row that looks like this:
ID participant: ID0215 Day1 Awake Time: 07:00 Day1 Bed Time: 22:00 Day2 Awake Time: 08:00 ........ till Day7 Bed Time
Then another row:
ID participant: ID5436 Day1 Awake Time: 06:00 Day1 Bed Time: 23:00.....
And then another row from another ID....and so on
If I want to analyze the data from ID0215sec.csv, then it needs to recognize the data times in the corresponding row in the Diaryrecord. Then it needs to exclude all the data in ID0215sec.csv that is NOT between the awake time and bed time for ALL days in the ID0215sec.csv file.
I hope this is a bit more clear and that you can help
Jan
2018년 5월 3일
@Debbie: Sorry, I still do not get it.
Then it needs to exclude all the data in ID0215sec.csv that is
NOT between the awake time and bed time for ALL days in the
ID0215sec.csv file.
Exclude from what? Did you import the Diaryrecord file already? From the display in your comment it is not clear, if this is a tab separated file or an Excel file. You mentioned, that it is a "CSV" file, but there are no commas.
The description as text is too general to be understood by somebody, who is not familiar with what you want. Split the task into pieces: 1. Import the CSV file, 2. parse the fields to get the times numerically, etc. Then you do not have to struggle with details like "the CSV file...", because this step is solved already. This will simplify the descriptions automatically, because you do not have to mention the whole job, but can focus on a single step: "I have a cell string of names and want to exclude all names inside a certain numerical limit".
Do you see how breaking the job into pieces works? This will help you to write the code and to ask a specific question in the forum.
Debbie Oomen
2018년 5월 4일
I have matched the diaryrecord row to the filename by using strcmpi. So if I choose file ID118sec.csv, MATLAB will find the row in the diary record belonging to this file. The diaryrecord row includes the wake and bed times for all days data is acquired. So now I need the code to identify the wake and bed times in the ID118sec.csv file and delete all other data that is not between wake and bed time.
Jan
2018년 5월 5일
Okay. I still cannot imagine, what these sentences mean as Matlab code. But let's care about your problems: What is your question now? Explaining the purpose of the code by telling it as a story is rarley useful. See Tutorial: How to ask a good question .
답변 (0개)
참고 항목
카테고리
Help Center 및 File Exchange에서 Tables에 대해 자세히 알아보기
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!오류 발생
페이지가 변경되었기 때문에 동작을 완료할 수 없습니다. 업데이트된 상태를 보려면 페이지를 다시 불러오십시오.
웹사이트 선택
번역된 콘텐츠를 보고 지역별 이벤트와 혜택을 살펴보려면 웹사이트를 선택하십시오. 현재 계신 지역에 따라 다음 웹사이트를 권장합니다:
또한 다음 목록에서 웹사이트를 선택하실 수도 있습니다.
사이트 성능 최적화 방법
최고의 사이트 성능을 위해 중국 사이트(중국어 또는 영어)를 선택하십시오. 현재 계신 지역에서는 다른 국가의 MathWorks 사이트 방문이 최적화되지 않았습니다.
미주
- América Latina (Español)
- Canada (English)
- United States (English)
유럽
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
아시아 태평양
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)
