필터 지우기
필터 지우기

Info

이 질문은 마감되었습니다. 편집하거나 답변을 올리려면 질문을 다시 여십시오.

Statistical processing of dynamic variables

조회 수: 1 (최근 30일)
katha_lala
katha_lala 2018년 1월 10일
마감: MATLAB Answer Bot 2021년 8월 20일
Hello everybody,
I am fairly new to Matlab and trying to understand the dynamic portion with structures etc. To be more specific about my problem: Let's say, I have a big amount of data from subjects in my study. I saved them in structures in single mat-files like this:
CT01_900_1, CT01_900_2, CT01_900_3
CT01_1100_1, CT01_1100_2, CT01_1100_3, etc. until CT01_1100_9;
CT01_1300_1, CT01_1300_2, CT01_1300_3;
The same goes for subject No 2 with CT02_900_1 etc. etc. - Note: there are always three measurements per subsection, except for the 1100 one, it has nine subsections.
So far, I have already written a program, where I can select multiple files via uigetfile and load them into the workspace. That works perfectly. This means, I have the FileName and the PathName. I named the structure mat-files exactly like my storage system to make it easier and more dynamic.
Now, I want to calculate the mean value and Std of each field "Ring1" and "Ring2" and "Ring3" (columns of numbers) of which every single structure is filled. How can I do this, depending on the selected files? Right now, I chose the easy but VERY inefficient way and kind of hardcoded it like this:
if exist('CT01_900_1') == 1 %checks if file is loaded in workspace to be processed
a=mean(CT01_900_1(1,1).Ring1); %Mean + Std for Ring 1 of CT01_900_1
CT01_900_1(1,1).MeanRing1=a;
a=std(CT01_900_1(1,1).Ring1);
CT01_900_1(1,1).StdRing1=a;
a=mean(CT01_900_1(1,1).Ring2); %Mean + Std for Ring 2 of CT01_900_1
CT01_900_1(1,1).MeanRing2=a;
a=std(_900_1(1,1).Ring2);
CT01_900_1(1,1).StdRing2=a;
a=mean(CT01_900_1(1,1).Ring3); %Mean + Std for Ring 3 of CT01_900_1
CT01_900_1(1,1).MeanRing3=a;
a=std(CT01_900_1(1,1).Ring3);
CT01_900_1(1,1).StdRing3=a;
else
disp('File not existent.')
return;
end
And I could do this like this for every subsection and sub-subsection per subject. For everyone of my subject. And I would copy and paste for the rest of my life.
I am pretty sure that there MUST be a more elegant way to do this in a combined loop or so, using the variable FileName (w/o the .mat ending, I guess) that stores all the filenames in a cell array. But I don't know how to, too many structures and loops and variables that are dynamic.
Or should I just do the "kind of elegant" way and solve everything via the input function like the following example:
SubID=input('SubID:') %if it consists of letters and numbers, pls type it as string, e.g. 'CT01'
time=input('time:') %time = e.g. 900 (9 o'clock), 1100 etc.)
measurementNo=input('measurementNo:') %day 1 = 1, day 2 = 2 etc.
... and combine everything via strcat later? but those are also many additional things to type into the command window. It would be nicer to have it automated basically.
Thanks for your help!

답변 (0개)

이 질문은 마감되었습니다.

Community Treasure Hunt

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

Start Hunting!

Translated by