フィルターのクリア

How to load my MAT files into a structure

7 ビュー (過去 30 日間)
Denni Purcell
Denni Purcell 2017 年 4 月 10 日
編集済み: Stephen23 2017 年 4 月 10 日
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 件のコメント
Stephen23
Stephen23 2017 年 4 月 10 日
編集済み: Stephen23 2017 年 4 月 10 日
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.

サインインしてコメントする。

回答 (0 件)

カテゴリ

Help Center および File ExchangeVariables についてさらに検索

タグ

Community Treasure Hunt

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

Start Hunting!

Translated by