Conversion to double from struct is not possible.

4 ビュー (過去 30 日間)
Víctor Magdaleno
Víctor Magdaleno 2020 年 7 月 30 日
コメント済み: Víctor Magdaleno 2020 年 8 月 8 日
Hello everyone,
I'm a matlab beginner. I imported txt files to matlab whitout problem, so I want to remove all DC noise of them in a loop. Could someone help me to reach this goal?
Filenames = dir('*mat');
numfiles1 = length(Filenames);
EEGSinDC = [];
for i = 1 : numfiles1
load (Filenames(i).name);
EEGSinDC(i) = Filenames(i);
EEGsinDC = EEGSinDC(i) - mean(EEGSinDC(i));
end
Conversion to double from struct is not possible.
  2 件のコメント
James Tursa
James Tursa 2020 年 7 月 30 日
What variables are in the mat files?
Stephen23
Stephen23 2020 年 7 月 30 日
Víctor Magdaleno's incorrectly posted "Answer" moved here:
registro is the variable

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

採用された回答

Alan Moses
Alan Moses 2020 年 8 月 6 日
The variable name can be used to select only the required data from the MAT file. To save the changes made to your data back to the MAT file, you can use the save function.You can use this piece of code to solve the issue:
Filenames = dir('*mat');
numfiles1 = length(Filenames);
for i = 1 : numfiles1
%replace with your variable name in the below line of code
load(Filenames(i).name, 'variableName');
variableName = variableName - mean(variableName);
%save(Filenames(i).name,' variableName ');
end
Alternately, you can use the matfile function if you wish to change the variables without loading the data into the workspace.
  1 件のコメント
Víctor Magdaleno
Víctor Magdaleno 2020 年 8 月 8 日
thank you! It works properly now.

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

その他の回答 (1 件)

Walter Roberson
Walter Roberson 2020 年 8 月 6 日
Filenames = dir('*mat');
numfiles1 = length(Filenames);
EEGSinDC = cell(numfiles1, 1);
for i = 1 : numfiles1
filedata = load(Filenames(i).name);
EEGSinDC{i} = filedata.registro - mean(filedata.registro);
end
  1 件のコメント
Víctor Magdaleno
Víctor Magdaleno 2020 年 8 月 8 日
thank you! It works properly now.

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

カテゴリ

Help Center および File ExchangeData Type Conversion についてさらに検索

Community Treasure Hunt

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

Start Hunting!

Translated by