Conversion to double from struct is not possible.

2 vues (au cours des 30 derniers jours)
Víctor Magdaleno
Víctor Magdaleno le 30 Juil 2020
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 commentaires
James Tursa
James Tursa le 30 Juil 2020
What variables are in the mat files?
Stephen23
Stephen23 le 30 Juil 2020
Víctor Magdaleno's incorrectly posted "Answer" moved here:
registro is the variable

Connectez-vous pour commenter.

Réponse acceptée

Alan Moses
Alan Moses le 6 Août 2020
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 commentaire
Víctor Magdaleno
Víctor Magdaleno le 8 Août 2020
thank you! It works properly now.

Connectez-vous pour commenter.

Plus de réponses (1)

Walter Roberson
Walter Roberson le 6 Août 2020
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 commentaire
Víctor Magdaleno
Víctor Magdaleno le 8 Août 2020
thank you! It works properly now.

Connectez-vous pour commenter.

Catégories

En savoir plus sur Data Type Conversion 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