Effacer les filtres
Effacer les filtres

How to load my MAT files into a structure

7 vues (au cours des 30 derniers jours)
Denni Purcell
Denni Purcell le 10 Avr 2017
Modifié(e) : Stephen23 le 10 Avr 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 commentaire
Stephen23
Stephen23 le 10 Avr 2017
Modifié(e) : Stephen23 le 10 Avr 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.

Connectez-vous pour commenter.

Réponses (0)

Catégories

En savoir plus sur Variables dans Help Center et File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by