Filter löschen
Filter löschen

How to load my MAT files into a structure

7 Ansichten (letzte 30 Tage)
Denni Purcell
Denni Purcell am 10 Apr. 2017
Bearbeitet: Stephen23 am 10 Apr. 2017
I am looking to write a code where the Mat files I import are stacked together. I have started the code like this:
prompt = {'Enter Number of therapists','Enter number of trials' };
dlg_title = 'Input Report Information';
num_lines = 1;
Input = inputdlg(prompt,dlg_title,num_lines);
Therapist_number = char(Input(1));
Trial_number = char(Input(2));
I would like to open the file with the number of therapists listed and then have the number of trials underneath it.
Previously I have used a code which stacked my data but now I would like it stacked in relation to the input number of therapists and trial number. This old section of code is written with a specific number of inputs.
cd(pname)
[filename, pathname, ~] = uigetfile( ...
{ '*.mat','mat-files (*.mat)'}, ...
'Select condition one mat file');
load([pathname filename])
COND_DATE = filename(8:19);
Condition_1 = COND_DATE(1:4);
Condition_1_YEAR = COND_DATE(5:8);
All mat files have a similar title 'COND_DATE' and I have uploaded a sample Mat file. I would like all my data stacked under the 'MEAN' and 'SD' headings. So it will be: MEAN > Therapist 1 > Trial 1 > Trial 2 > Therapist 2 > Trial 1 > Trial 2 * with the possibility to have more therapists & trials depending on the input
  1 Kommentar
Stephen23
Stephen23 am 10 Apr. 2017
Bearbeitet: Stephen23 am 10 Apr. 2017
Some comments:
  1. using fullfile is much better than concatenating the filepath and filename.
  2. You should load your data into a variable, rather than directly into the workspace. This then also makes it trivial to create a non-scalar structure directly in a loop when the data is loaded.
  3. load the data first (into a non-scalar structure), then rearrange it, if required.

Melden Sie sich an, um zu kommentieren.

Antworten (0)

Kategorien

Mehr zu Variables finden Sie in Help Center und File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by