Category: News
Who explain me this code ?
% Section 1 : Chargement des noms de fichiers et dates
filenames = dir; % Récupère la liste des fichiers dans le répertoire courant
clear files dates % Efface les variables ‘files’ et ‘dates’ si elles existent
for i = 3:size(filenames, 1) % Boucle à partir du troisième élément pour ignorer ‘.’ et ‘..’
files{i-2} = filenames(i).name; % Stocke le nom du fichier dans ‘files’
dates{i-2} = filenames(i).date; % Stocke la date du fichier dans ‘dates’
end
% Section 2 : Chargement des images
clear I % Efface la variable ‘I’ si elle existe
ii = 1; % Initialise l’index pour les images chargées
for i = 1:size(files, 2) % Boucle sur tous les fichiers
try
I{ii} = imread(files{i}); % Tente de lire l’image et la stocke dans ‘I’
ii = ii + 1; % Incrémente l’index
catch
i % Affiche l’index de l’image qui ne peut pas être lue
end
end
% Section 3 : Extraction des visages
for i = 1:29 % Boucle sur les 29 premières images
Face(:, :, i) = extractFace(I{i}); % Extrait le visage de l’image et le stocke dans ‘Face’
end
for i = 1:29 % Boucle pour afficher les visages extraits
figure
image(Face(:, :, i)); colormap(gray); % Affiche le visage en niveaux de gris
end
% Section 4 : Conversion des images en vecteurs
clear X % Efface la variable ‘X’ si elle existe
for i = 1:29 % Boucle sur les 29 visages extraits
X(:, i) = reshape(Face(:, :, i), [10000 1]); % Convertit chaque visage en un vecteur de 10000 éléments
end
imagesc(X) % Affiche la matrice ‘X’ sous forme d’image
% Section 5 : Calcul du visage moyen
averageFace = mean(X, 2); % Calcule le visage moyen en prenant la moyenne de chaque ligne de ‘X’
imagesc(reshape(averageFace, [100 100])); colormap(gray); % Affiche le visage moyen
% Section 6 : Soustraction du visage moyen
A = double(X) – averageFace; % Soustrait le visage moyen de chaque colonne de ‘X’
% Section 7 : Décomposition en valeurs singulières (SVD)
[U, S, D] = svds(A, 15); % Effectue une SVD sur ‘A’ pour obtenir les 15 valeurs singulières et vecteurs principaux
% Section 8 : Affichage des valeurs singulières
diag(S) % Affiche les valeurs singulières sous forme de vecteur diagonal
% Section 9 : Affichage des Eigenfaces
for i = 1:9 % Boucle pour afficher les 9 premiers eigenfaces
figure
imagesc(reshape(U(:, i), [100 100])); % Affiche chaque eigenface
colormap(gray);
end
% Section 10 : Reconnaissance de visage
RegFace = X(:, 9); % Sélectionne un visage de référence dans ‘X’
imagesc(reshape(RegFace, [100 100])); colormap(gray); axis image; % Affiche le visage de référence
LFace = U’ * (double(RegFace) – averageFace); % Projette le visage de référence dans l’espace des visages
HFace = U * LFace + averageFace; % Reconstitue le visage à partir de l’espace des visages
imagesc(reshape(HFace, [100 100])); colormap(gray); axis image; % Affiche le visage reconstitué
% Section 11 : Reconnaissance d’un visage inconnu
I = imread("18-1.jpg"); % Charge une nouvelle image
UnknownCrop = extractFace(I); % Extrait le visage de l’image
imagesc(UnknownCrop) % Affiche le visage extrait
RegFace = reshape(UnknownCrop, [10000 1]); % Convertit le visage extrait en vecteur
LFace = U’ * (double(RegFace) – averageFace); % Projette le visage extrait dans l’espace des visages
HFace = U * LFace + averageFace; % Reconstitue le visage extrait
imagesc(reshape(HFace, [100 100])); colormap(gray); % Affiche le visage reconstitué
———————————————————————————————————————————-
% Etape 1 : Conversion de l’image en espace de couleur YCbCr et détection de la région du visage
I5 = imread(‘path_to_image.jpg’); % Charger l’image (remplace ‘path_to_image.jpg’ par le chemin réel)
YI = rgb2ycbcr(I5); % Convertit l’image RGB en YCbCr
FaceArea = (YI(:, :, 3) > 140); % Crée une masque binaire pour détecter la région du visage
imagesc(FaceArea) % Affiche la région détectée
figure; plot(sum(FaceArea)) % Affiche la somme des pixels de la région détectée selon les colonnes
figure; plot(sum(FaceArea’)) % Affiche la somme des pixels de la région détectée selon les lignes
Xindices = find(sum(FaceArea) > 100); % Trouve les indices des colonnes avec une somme de pixels supérieure à 100
Xmin = min(Xindices); % Trouve l’indice minimum des colonnes
Xmax = max(Xindices); % Trouve l’indice maximum des colonnes
Yindices = find(sum(FaceArea’) > 100); % Trouve les indices des lignes avec une somme de pixels supérieure à 100
Ymin = min(Yindices); % Trouve l’indice minimum des lignes
Ymax = max(Yindices); % Trouve l’indice maximum des lignes
% Etape 2 : Détection des cercles (yeux) dans l’image
I = imread(’23-1.jpg’); % Charger une nouvelle image
[centersDark, radiiDark] = imfindcircles(rgb2gray(I), [25 50], ‘ObjectPolarity’, ‘dark’, ‘Sensitivity’, 0.9); % Trouve les cercles dans l’image
image(I) % Affiche l’image
viscircles(centersDark, radiiDark, ‘EdgeColor’, ‘y’) % Superpose les cercles détectés sur l’image
% Dernière étape : PCA pour la reconnaissance faciale
% Etape 3 : Chargement des données de visages
load(‘faces.mat’) % Charger les données de visages préalablement sauvegardées
% Etape 4 : Conversion des images de visages en vecteurs
clear X % Efface la variable ‘X’ si elle existe
for i = 1:29 % Boucle sur les 29 visages extraits
X(:, i) = reshape(Face(:, :, i), [10000 1]); % Convertit chaque visage en un vecteur de 10000 éléments
end
% Etape 5 : Calcul du visage moyen
averageFace = mean(X, 2); % Calcule le visage moyen en prenant la moyenne de chaque ligne de ‘X’
% Etape 6 : Soustraction du visage moyen
A = double(X) – averageFace; % Soustrait le visage moyen de chaque colonne de ‘X’
% Etape 7 : Décomposition en valeurs singulières (SVD)
[U, S, V] = svds(A, 15); % Effectue une SVD sur ‘A’ pour obtenir les 15 valeurs singulières et vecteurs principaux
% Etape 13 : Projection des visages d’entraînement dans l’espace des visages
LowTrainFaces = U’ * A; % Projette les visages d’entraînement dans l’espace des visages
% Etape 14 : Reconnaissance d’un visage inconnu
I = imread(’21-4.jpg’); % Charge une nouvelle image
Crop = extractFace(I); % Extrait le visage de l’image
imagesc(Crop) % Affiche le visage extrait
UnknownVec = reshape(Crop, [10000 1]); % Convertit le visage extrait en vecteur
LowUnknownVec = U’ * (double(UnknownVec) – averageFace); % Projette le visage extrait dans l’espace des visages
EuclideanDist = sqrt(sum((LowTrainFaces – LowUnknownVec).^2)); % Calcule la distance euclidienne entre le visage inconnu et les visages d’entraînement
[minDist, minIndex] = min(EuclideanDist); % Trouve la distance minimale et l’index du visage correspondant
figure; imagesc(Face(:, :, minIndex)) % Affiche le visage correspondant
[sortDist, sortIndex] = sort(EuclideanDist, ‘ascend’); % Trie les distances euclidiennes par ordre croissant
imagesc(Face(:, :, sortIndex(7))) % Affiche le septième visage le plus proche% Section 1 : Chargement des noms de fichiers et dates
filenames = dir; % Récupère la liste des fichiers dans le répertoire courant
clear files dates % Efface les variables ‘files’ et ‘dates’ si elles existent
for i = 3:size(filenames, 1) % Boucle à partir du troisième élément pour ignorer ‘.’ et ‘..’
files{i-2} = filenames(i).name; % Stocke le nom du fichier dans ‘files’
dates{i-2} = filenames(i).date; % Stocke la date du fichier dans ‘dates’
end
% Section 2 : Chargement des images
clear I % Efface la variable ‘I’ si elle existe
ii = 1; % Initialise l’index pour les images chargées
for i = 1:size(files, 2) % Boucle sur tous les fichiers
try
I{ii} = imread(files{i}); % Tente de lire l’image et la stocke dans ‘I’
ii = ii + 1; % Incrémente l’index
catch
i % Affiche l’index de l’image qui ne peut pas être lue
end
end
% Section 3 : Extraction des visages
for i = 1:29 % Boucle sur les 29 premières images
Face(:, :, i) = extractFace(I{i}); % Extrait le visage de l’image et le stocke dans ‘Face’
end
for i = 1:29 % Boucle pour afficher les visages extraits
figure
image(Face(:, :, i)); colormap(gray); % Affiche le visage en niveaux de gris
end
% Section 4 : Conversion des images en vecteurs
clear X % Efface la variable ‘X’ si elle existe
for i = 1:29 % Boucle sur les 29 visages extraits
X(:, i) = reshape(Face(:, :, i), [10000 1]); % Convertit chaque visage en un vecteur de 10000 éléments
end
imagesc(X) % Affiche la matrice ‘X’ sous forme d’image
% Section 5 : Calcul du visage moyen
averageFace = mean(X, 2); % Calcule le visage moyen en prenant la moyenne de chaque ligne de ‘X’
imagesc(reshape(averageFace, [100 100])); colormap(gray); % Affiche le visage moyen
% Section 6 : Soustraction du visage moyen
A = double(X) – averageFace; % Soustrait le visage moyen de chaque colonne de ‘X’
% Section 7 : Décomposition en valeurs singulières (SVD)
[U, S, D] = svds(A, 15); % Effectue une SVD sur ‘A’ pour obtenir les 15 valeurs singulières et vecteurs principaux
% Section 8 : Affichage des valeurs singulières
diag(S) % Affiche les valeurs singulières sous forme de vecteur diagonal
% Section 9 : Affichage des Eigenfaces
for i = 1:9 % Boucle pour afficher les 9 premiers eigenfaces
figure
imagesc(reshape(U(:, i), [100 100])); % Affiche chaque eigenface
colormap(gray);
end
% Section 10 : Reconnaissance de visage
RegFace = X(:, 9); % Sélectionne un visage de référence dans ‘X’
imagesc(reshape(RegFace, [100 100])); colormap(gray); axis image; % Affiche le visage de référence
LFace = U’ * (double(RegFace) – averageFace); % Projette le visage de référence dans l’espace des visages
HFace = U * LFace + averageFace; % Reconstitue le visage à partir de l’espace des visages
imagesc(reshape(HFace, [100 100])); colormap(gray); axis image; % Affiche le visage reconstitué
% Section 11 : Reconnaissance d’un visage inconnu
I = imread("18-1.jpg"); % Charge une nouvelle image
UnknownCrop = extractFace(I); % Extrait le visage de l’image
imagesc(UnknownCrop) % Affiche le visage extrait
RegFace = reshape(UnknownCrop, [10000 1]); % Convertit le visage extrait en vecteur
LFace = U’ * (double(RegFace) – averageFace); % Projette le visage extrait dans l’espace des visages
HFace = U * LFace + averageFace; % Reconstitue le visage extrait
imagesc(reshape(HFace, [100 100])); colormap(gray); % Affiche le visage reconstitué
———————————————————————————————————————————-
% Etape 1 : Conversion de l’image en espace de couleur YCbCr et détection de la région du visage
I5 = imread(‘path_to_image.jpg’); % Charger l’image (remplace ‘path_to_image.jpg’ par le chemin réel)
YI = rgb2ycbcr(I5); % Convertit l’image RGB en YCbCr
FaceArea = (YI(:, :, 3) > 140); % Crée une masque binaire pour détecter la région du visage
imagesc(FaceArea) % Affiche la région détectée
figure; plot(sum(FaceArea)) % Affiche la somme des pixels de la région détectée selon les colonnes
figure; plot(sum(FaceArea’)) % Affiche la somme des pixels de la région détectée selon les lignes
Xindices = find(sum(FaceArea) > 100); % Trouve les indices des colonnes avec une somme de pixels supérieure à 100
Xmin = min(Xindices); % Trouve l’indice minimum des colonnes
Xmax = max(Xindices); % Trouve l’indice maximum des colonnes
Yindices = find(sum(FaceArea’) > 100); % Trouve les indices des lignes avec une somme de pixels supérieure à 100
Ymin = min(Yindices); % Trouve l’indice minimum des lignes
Ymax = max(Yindices); % Trouve l’indice maximum des lignes
% Etape 2 : Détection des cercles (yeux) dans l’image
I = imread(’23-1.jpg’); % Charger une nouvelle image
[centersDark, radiiDark] = imfindcircles(rgb2gray(I), [25 50], ‘ObjectPolarity’, ‘dark’, ‘Sensitivity’, 0.9); % Trouve les cercles dans l’image
image(I) % Affiche l’image
viscircles(centersDark, radiiDark, ‘EdgeColor’, ‘y’) % Superpose les cercles détectés sur l’image
% Dernière étape : PCA pour la reconnaissance faciale
% Etape 3 : Chargement des données de visages
load(‘faces.mat’) % Charger les données de visages préalablement sauvegardées
% Etape 4 : Conversion des images de visages en vecteurs
clear X % Efface la variable ‘X’ si elle existe
for i = 1:29 % Boucle sur les 29 visages extraits
X(:, i) = reshape(Face(:, :, i), [10000 1]); % Convertit chaque visage en un vecteur de 10000 éléments
end
% Etape 5 : Calcul du visage moyen
averageFace = mean(X, 2); % Calcule le visage moyen en prenant la moyenne de chaque ligne de ‘X’
% Etape 6 : Soustraction du visage moyen
A = double(X) – averageFace; % Soustrait le visage moyen de chaque colonne de ‘X’
% Etape 7 : Décomposition en valeurs singulières (SVD)
[U, S, V] = svds(A, 15); % Effectue une SVD sur ‘A’ pour obtenir les 15 valeurs singulières et vecteurs principaux
% Etape 13 : Projection des visages d’entraînement dans l’espace des visages
LowTrainFaces = U’ * A; % Projette les visages d’entraînement dans l’espace des visages
% Etape 14 : Reconnaissance d’un visage inconnu
I = imread(’21-4.jpg’); % Charge une nouvelle image
Crop = extractFace(I); % Extrait le visage de l’image
imagesc(Crop) % Affiche le visage extrait
UnknownVec = reshape(Crop, [10000 1]); % Convertit le visage extrait en vecteur
LowUnknownVec = U’ * (double(UnknownVec) – averageFace); % Projette le visage extrait dans l’espace des visages
EuclideanDist = sqrt(sum((LowTrainFaces – LowUnknownVec).^2)); % Calcule la distance euclidienne entre le visage inconnu et les visages d’entraînement
[minDist, minIndex] = min(EuclideanDist); % Trouve la distance minimale et l’index du visage correspondant
figure; imagesc(Face(:, :, minIndex)) % Affiche le visage correspondant
[sortDist, sortIndex] = sort(EuclideanDist, ‘ascend’); % Trie les distances euclidiennes par ordre croissant
imagesc(Face(:, :, sortIndex(7))) % Affiche le septième visage le plus proche % Section 1 : Chargement des noms de fichiers et dates
filenames = dir; % Récupère la liste des fichiers dans le répertoire courant
clear files dates % Efface les variables ‘files’ et ‘dates’ si elles existent
for i = 3:size(filenames, 1) % Boucle à partir du troisième élément pour ignorer ‘.’ et ‘..’
files{i-2} = filenames(i).name; % Stocke le nom du fichier dans ‘files’
dates{i-2} = filenames(i).date; % Stocke la date du fichier dans ‘dates’
end
% Section 2 : Chargement des images
clear I % Efface la variable ‘I’ si elle existe
ii = 1; % Initialise l’index pour les images chargées
for i = 1:size(files, 2) % Boucle sur tous les fichiers
try
I{ii} = imread(files{i}); % Tente de lire l’image et la stocke dans ‘I’
ii = ii + 1; % Incrémente l’index
catch
i % Affiche l’index de l’image qui ne peut pas être lue
end
end
% Section 3 : Extraction des visages
for i = 1:29 % Boucle sur les 29 premières images
Face(:, :, i) = extractFace(I{i}); % Extrait le visage de l’image et le stocke dans ‘Face’
end
for i = 1:29 % Boucle pour afficher les visages extraits
figure
image(Face(:, :, i)); colormap(gray); % Affiche le visage en niveaux de gris
end
% Section 4 : Conversion des images en vecteurs
clear X % Efface la variable ‘X’ si elle existe
for i = 1:29 % Boucle sur les 29 visages extraits
X(:, i) = reshape(Face(:, :, i), [10000 1]); % Convertit chaque visage en un vecteur de 10000 éléments
end
imagesc(X) % Affiche la matrice ‘X’ sous forme d’image
% Section 5 : Calcul du visage moyen
averageFace = mean(X, 2); % Calcule le visage moyen en prenant la moyenne de chaque ligne de ‘X’
imagesc(reshape(averageFace, [100 100])); colormap(gray); % Affiche le visage moyen
% Section 6 : Soustraction du visage moyen
A = double(X) – averageFace; % Soustrait le visage moyen de chaque colonne de ‘X’
% Section 7 : Décomposition en valeurs singulières (SVD)
[U, S, D] = svds(A, 15); % Effectue une SVD sur ‘A’ pour obtenir les 15 valeurs singulières et vecteurs principaux
% Section 8 : Affichage des valeurs singulières
diag(S) % Affiche les valeurs singulières sous forme de vecteur diagonal
% Section 9 : Affichage des Eigenfaces
for i = 1:9 % Boucle pour afficher les 9 premiers eigenfaces
figure
imagesc(reshape(U(:, i), [100 100])); % Affiche chaque eigenface
colormap(gray);
end
% Section 10 : Reconnaissance de visage
RegFace = X(:, 9); % Sélectionne un visage de référence dans ‘X’
imagesc(reshape(RegFace, [100 100])); colormap(gray); axis image; % Affiche le visage de référence
LFace = U’ * (double(RegFace) – averageFace); % Projette le visage de référence dans l’espace des visages
HFace = U * LFace + averageFace; % Reconstitue le visage à partir de l’espace des visages
imagesc(reshape(HFace, [100 100])); colormap(gray); axis image; % Affiche le visage reconstitué
% Section 11 : Reconnaissance d’un visage inconnu
I = imread("18-1.jpg"); % Charge une nouvelle image
UnknownCrop = extractFace(I); % Extrait le visage de l’image
imagesc(UnknownCrop) % Affiche le visage extrait
RegFace = reshape(UnknownCrop, [10000 1]); % Convertit le visage extrait en vecteur
LFace = U’ * (double(RegFace) – averageFace); % Projette le visage extrait dans l’espace des visages
HFace = U * LFace + averageFace; % Reconstitue le visage extrait
imagesc(reshape(HFace, [100 100])); colormap(gray); % Affiche le visage reconstitué
———————————————————————————————————————————-
% Etape 1 : Conversion de l’image en espace de couleur YCbCr et détection de la région du visage
I5 = imread(‘path_to_image.jpg’); % Charger l’image (remplace ‘path_to_image.jpg’ par le chemin réel)
YI = rgb2ycbcr(I5); % Convertit l’image RGB en YCbCr
FaceArea = (YI(:, :, 3) > 140); % Crée une masque binaire pour détecter la région du visage
imagesc(FaceArea) % Affiche la région détectée
figure; plot(sum(FaceArea)) % Affiche la somme des pixels de la région détectée selon les colonnes
figure; plot(sum(FaceArea’)) % Affiche la somme des pixels de la région détectée selon les lignes
Xindices = find(sum(FaceArea) > 100); % Trouve les indices des colonnes avec une somme de pixels supérieure à 100
Xmin = min(Xindices); % Trouve l’indice minimum des colonnes
Xmax = max(Xindices); % Trouve l’indice maximum des colonnes
Yindices = find(sum(FaceArea’) > 100); % Trouve les indices des lignes avec une somme de pixels supérieure à 100
Ymin = min(Yindices); % Trouve l’indice minimum des lignes
Ymax = max(Yindices); % Trouve l’indice maximum des lignes
% Etape 2 : Détection des cercles (yeux) dans l’image
I = imread(’23-1.jpg’); % Charger une nouvelle image
[centersDark, radiiDark] = imfindcircles(rgb2gray(I), [25 50], ‘ObjectPolarity’, ‘dark’, ‘Sensitivity’, 0.9); % Trouve les cercles dans l’image
image(I) % Affiche l’image
viscircles(centersDark, radiiDark, ‘EdgeColor’, ‘y’) % Superpose les cercles détectés sur l’image
% Dernière étape : PCA pour la reconnaissance faciale
% Etape 3 : Chargement des données de visages
load(‘faces.mat’) % Charger les données de visages préalablement sauvegardées
% Etape 4 : Conversion des images de visages en vecteurs
clear X % Efface la variable ‘X’ si elle existe
for i = 1:29 % Boucle sur les 29 visages extraits
X(:, i) = reshape(Face(:, :, i), [10000 1]); % Convertit chaque visage en un vecteur de 10000 éléments
end
% Etape 5 : Calcul du visage moyen
averageFace = mean(X, 2); % Calcule le visage moyen en prenant la moyenne de chaque ligne de ‘X’
% Etape 6 : Soustraction du visage moyen
A = double(X) – averageFace; % Soustrait le visage moyen de chaque colonne de ‘X’
% Etape 7 : Décomposition en valeurs singulières (SVD)
[U, S, V] = svds(A, 15); % Effectue une SVD sur ‘A’ pour obtenir les 15 valeurs singulières et vecteurs principaux
% Etape 13 : Projection des visages d’entraînement dans l’espace des visages
LowTrainFaces = U’ * A; % Projette les visages d’entraînement dans l’espace des visages
% Etape 14 : Reconnaissance d’un visage inconnu
I = imread(’21-4.jpg’); % Charge une nouvelle image
Crop = extractFace(I); % Extrait le visage de l’image
imagesc(Crop) % Affiche le visage extrait
UnknownVec = reshape(Crop, [10000 1]); % Convertit le visage extrait en vecteur
LowUnknownVec = U’ * (double(UnknownVec) – averageFace); % Projette le visage extrait dans l’espace des visages
EuclideanDist = sqrt(sum((LowTrainFaces – LowUnknownVec).^2)); % Calcule la distance euclidienne entre le visage inconnu et les visages d’entraînement
[minDist, minIndex] = min(EuclideanDist); % Trouve la distance minimale et l’index du visage correspondant
figure; imagesc(Face(:, :, minIndex)) % Affiche le visage correspondant
[sortDist, sortIndex] = sort(EuclideanDist, ‘ascend’); % Trie les distances euclidiennes par ordre croissant
imagesc(Face(:, :, sortIndex(7))) % Affiche le septième visage le plus proche pca MATLAB Answers — New Questions
Remove NaNs from struct fields embedded in a cell array
Good afternoon,
I have a strange problem occuring when using import data has started adding random lines of NaNs, I do not know why this has happened but I need to remove them.
Within the attached sample, the struct is contained within a cell array, as the original code loops. WIthin the struct, the data field contains the 2D matrix, what I need this for any rows with NaN added to be removed from each one.
Can you help please?
ThanksGood afternoon,
I have a strange problem occuring when using import data has started adding random lines of NaNs, I do not know why this has happened but I need to remove them.
Within the attached sample, the struct is contained within a cell array, as the original code loops. WIthin the struct, the data field contains the 2D matrix, what I need this for any rows with NaN added to be removed from each one.
Can you help please?
Thanks Good afternoon,
I have a strange problem occuring when using import data has started adding random lines of NaNs, I do not know why this has happened but I need to remove them.
Within the attached sample, the struct is contained within a cell array, as the original code loops. WIthin the struct, the data field contains the 2D matrix, what I need this for any rows with NaN added to be removed from each one.
Can you help please?
Thanks struct, cell array, nan MATLAB Answers — New Questions
After installing MATLAB 2024a, I get the following warnings and errors after startup
Warning: Initializing Java preferences failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:dispatcher:loadLibrary
C:Program FilesMATLABR2024abinwin64mcr.dll
Error using ismcc
C:Program FilesMATLABR2024abinwin64mcr.dll
Error occurred during deviceplugindetection initialization: C:Program
FilesMATLABR2024abinwin64mcr.dllWarning: Initializing Java preferences failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:dispatcher:loadLibrary
C:Program FilesMATLABR2024abinwin64mcr.dll
Error using ismcc
C:Program FilesMATLABR2024abinwin64mcr.dll
Error occurred during deviceplugindetection initialization: C:Program
FilesMATLABR2024abinwin64mcr.dll Warning: Initializing Java preferences failed in matlabrc.
This indicates a potentially serious problem in your MATLAB setup, which should be resolved as soon as possible. Error detected was:
MATLAB:dispatcher:loadLibrary
C:Program FilesMATLABR2024abinwin64mcr.dll
Error using ismcc
C:Program FilesMATLABR2024abinwin64mcr.dll
Error occurred during deviceplugindetection initialization: C:Program
FilesMATLABR2024abinwin64mcr.dll startup failure MATLAB Answers — New Questions
Problem With Deep Learning Toolbox
Im trying to open the Deep Learning Toolbox. The following error is returned:
Error using deepNetworkDesigner (line 29)
Invalid default value for property ‘Network’ in class ‘deepapp.internal.editor.import.NoArgsCallStrategy’:
Undefined function ‘mtimes’ for input arguments of type ‘nnet.cnn.layer.Layer’.
Similarly while calling a pretianed network in a code, following error is returned:
lgraphGoogLeNet = layerGraph(googlenet);
Warning: While loading an object of class ‘DAGNetwork’:
Too many input arguments.
Dot indexing is not supported for variables of this type.
Error in DAGNetwork/get.LayerGraph (line 188)
val = this.PrivateNetwork.LayerGraph;
Error in DAGNetwork/getLayerGraph (line 230)
layerGraph = this.LayerGraph;
Error in DAGNetwork/layerGraph (line 12)
internalLayerGraph = this.getLayerGraph();Im trying to open the Deep Learning Toolbox. The following error is returned:
Error using deepNetworkDesigner (line 29)
Invalid default value for property ‘Network’ in class ‘deepapp.internal.editor.import.NoArgsCallStrategy’:
Undefined function ‘mtimes’ for input arguments of type ‘nnet.cnn.layer.Layer’.
Similarly while calling a pretianed network in a code, following error is returned:
lgraphGoogLeNet = layerGraph(googlenet);
Warning: While loading an object of class ‘DAGNetwork’:
Too many input arguments.
Dot indexing is not supported for variables of this type.
Error in DAGNetwork/get.LayerGraph (line 188)
val = this.PrivateNetwork.LayerGraph;
Error in DAGNetwork/getLayerGraph (line 230)
layerGraph = this.LayerGraph;
Error in DAGNetwork/layerGraph (line 12)
internalLayerGraph = this.getLayerGraph(); Im trying to open the Deep Learning Toolbox. The following error is returned:
Error using deepNetworkDesigner (line 29)
Invalid default value for property ‘Network’ in class ‘deepapp.internal.editor.import.NoArgsCallStrategy’:
Undefined function ‘mtimes’ for input arguments of type ‘nnet.cnn.layer.Layer’.
Similarly while calling a pretianed network in a code, following error is returned:
lgraphGoogLeNet = layerGraph(googlenet);
Warning: While loading an object of class ‘DAGNetwork’:
Too many input arguments.
Dot indexing is not supported for variables of this type.
Error in DAGNetwork/get.LayerGraph (line 188)
val = this.PrivateNetwork.LayerGraph;
Error in DAGNetwork/getLayerGraph (line 230)
layerGraph = this.LayerGraph;
Error in DAGNetwork/layerGraph (line 12)
internalLayerGraph = this.getLayerGraph(); matlab, deep learning, toolbox MATLAB Answers — New Questions
No usable results when using insEKF() instead of imufilter()
Part of what I want to do is fuse gyroscope and accelerometer data to get an orientation estimate. When I fuse the data using the imufilter() I get results looking very similar to what I am expecting, without majorly tweaking the noise settings and so on.
I then proceeded to try to fuse it using the insEKF() because I eventually also need to fuse GPS measurements. For the first part I only added the gyroscope and the accelerometer to see the orientation estimate. I coded it very similar to the example in the documentation but for some reason the estimated orientation just start spinning and jumping around "uncontrollably".
Heres part of how Ive implemented it:
I also tried tuning it using the data I got from the other filter but that not seems like the issue. Also fusing the data sequentially using fuse() didnt change anything.
…
gyrofix=[gyro(:,2) gyro(:,3) gyro(:,1)]; %data already in workspace
acclfix=[-accl(:,2) -accl(:,3) -accl(:,1)];
option = insOptions(ReferenceFrame="ENU");
insAccel=insAccelerometer;
insGyro=insGyroscope;
tt_meas=timetable(acclfix,gyrofix,’RowTimes’, seconds(0:0.01:(size(acclfix,1)/100)-0.01))
tt_meas.Properties.VariableNames={‘Accelerometer’ ‘Gyroscope’}
tt_meas.Accelerometer(:,:)=0;
filt = insEKF(insAccel, insGyro, option);
initOrient=quaternion(1, 0, 0, 0);
stateparts(filt,"Orientation",compact(initOrient));
statecovparts(filt,"Orientation",0.01);
mnoise=tunernoise(filt);
mnoise.AccelerometerNoise=0.0002;
mnoise.GyroscopeNoise=9e-5;
untunedEst = estimateStates(filt,tt_meas,mnoise);Part of what I want to do is fuse gyroscope and accelerometer data to get an orientation estimate. When I fuse the data using the imufilter() I get results looking very similar to what I am expecting, without majorly tweaking the noise settings and so on.
I then proceeded to try to fuse it using the insEKF() because I eventually also need to fuse GPS measurements. For the first part I only added the gyroscope and the accelerometer to see the orientation estimate. I coded it very similar to the example in the documentation but for some reason the estimated orientation just start spinning and jumping around "uncontrollably".
Heres part of how Ive implemented it:
I also tried tuning it using the data I got from the other filter but that not seems like the issue. Also fusing the data sequentially using fuse() didnt change anything.
…
gyrofix=[gyro(:,2) gyro(:,3) gyro(:,1)]; %data already in workspace
acclfix=[-accl(:,2) -accl(:,3) -accl(:,1)];
option = insOptions(ReferenceFrame="ENU");
insAccel=insAccelerometer;
insGyro=insGyroscope;
tt_meas=timetable(acclfix,gyrofix,’RowTimes’, seconds(0:0.01:(size(acclfix,1)/100)-0.01))
tt_meas.Properties.VariableNames={‘Accelerometer’ ‘Gyroscope’}
tt_meas.Accelerometer(:,:)=0;
filt = insEKF(insAccel, insGyro, option);
initOrient=quaternion(1, 0, 0, 0);
stateparts(filt,"Orientation",compact(initOrient));
statecovparts(filt,"Orientation",0.01);
mnoise=tunernoise(filt);
mnoise.AccelerometerNoise=0.0002;
mnoise.GyroscopeNoise=9e-5;
untunedEst = estimateStates(filt,tt_meas,mnoise); Part of what I want to do is fuse gyroscope and accelerometer data to get an orientation estimate. When I fuse the data using the imufilter() I get results looking very similar to what I am expecting, without majorly tweaking the noise settings and so on.
I then proceeded to try to fuse it using the insEKF() because I eventually also need to fuse GPS measurements. For the first part I only added the gyroscope and the accelerometer to see the orientation estimate. I coded it very similar to the example in the documentation but for some reason the estimated orientation just start spinning and jumping around "uncontrollably".
Heres part of how Ive implemented it:
I also tried tuning it using the data I got from the other filter but that not seems like the issue. Also fusing the data sequentially using fuse() didnt change anything.
…
gyrofix=[gyro(:,2) gyro(:,3) gyro(:,1)]; %data already in workspace
acclfix=[-accl(:,2) -accl(:,3) -accl(:,1)];
option = insOptions(ReferenceFrame="ENU");
insAccel=insAccelerometer;
insGyro=insGyroscope;
tt_meas=timetable(acclfix,gyrofix,’RowTimes’, seconds(0:0.01:(size(acclfix,1)/100)-0.01))
tt_meas.Properties.VariableNames={‘Accelerometer’ ‘Gyroscope’}
tt_meas.Accelerometer(:,:)=0;
filt = insEKF(insAccel, insGyro, option);
initOrient=quaternion(1, 0, 0, 0);
stateparts(filt,"Orientation",compact(initOrient));
statecovparts(filt,"Orientation",0.01);
mnoise=tunernoise(filt);
mnoise.AccelerometerNoise=0.0002;
mnoise.GyroscopeNoise=9e-5;
untunedEst = estimateStates(filt,tt_meas,mnoise); sensor fusion, inertial, filter, ekf, insekf MATLAB Answers — New Questions
Navigate around the ribbon using links shortcut on Mac
The feature is explained here in a youtube video
I’ve seen this feature around where when you press the alt key (in Windows) links(letters and numbers) appears on the ribbon under all items and when you can press a button (letter/number) it basically click the corresponding item under the ribbon. Is there anyone who knows how to get this feature on Mac?on Mac?
The feature is explained here in a youtube video I’ve seen this feature around where when you press the alt key (in Windows) links(letters and numbers) appears on the ribbon under all items and when you can press a button (letter/number) it basically click the corresponding item under the ribbon. Is there anyone who knows how to get this feature on Mac?on Mac? Read More
Disabling auto creation
I’ve discovered that somehow Microsoft Outlook stores (somewhere in the Cloud?) every single email contact I’ve ever made, even if the recipient isn’t in our PC address list! Yes it’s a bit late to find out, and I can see why it could be helpful to some, but I want to STOP it happening! Is there any way to do this, perhaps by ticking a box somewhere I haven’t noticed? And is there any way to delete all the stuff from past years that I don’t want? I’d like my address book just to contain those addresses I currently use (partly because some addresses are long dead!!!!).
I’ve had this autoresponse from a computer forum:
To prevent Outlook from automatically storing every email contact you make, you can adjust the contact sync settings or disable the automatic creation of contacts for email recipients in the Outlook settings.”
but I’ve now tried for several hours to follow this advice and I can’t find any way of doing it, or any box to tick or untick in the settings options.
Any help would be much appreciated.
I’ve discovered that somehow Microsoft Outlook stores (somewhere in the Cloud?) every single email contact I’ve ever made, even if the recipient isn’t in our PC address list! Yes it’s a bit late to find out, and I can see why it could be helpful to some, but I want to STOP it happening! Is there any way to do this, perhaps by ticking a box somewhere I haven’t noticed? And is there any way to delete all the stuff from past years that I don’t want? I’d like my address book just to contain those addresses I currently use (partly because some addresses are long dead!!!!). I’ve had this autoresponse from a computer forum: To prevent Outlook from automatically storing every email contact you make, you can adjust the contact sync settings or disable the automatic creation of contacts for email recipients in the Outlook settings.”but I’ve now tried for several hours to follow this advice and I can’t find any way of doing it, or any box to tick or untick in the settings options. Any help would be much appreciated. Read More
School assignment
I’m supposed to load a analysis toolpak on to my Excel. I don’t know if I am doing something wrong. Please help me figure out if I have loaded it or what I am doing wrong.
Desperately
Taquyia Carter
I’m supposed to load a analysis toolpak on to my Excel. I don’t know if I am doing something wrong. Please help me figure out if I have loaded it or what I am doing wrong. Desperately Taquyia Carter Read More
How to find the line of intersection between the following two planes and plot the intersected line on the same two planes?
How to find the line of intersection between the following two planes and plot the intersected line on the same two planes?
The following points contain the following points:
The first plane:
P1 = 177668442.453315 -102576923.076923 0
P2 = -102576923.076923 177668442.453315 -102576923.076923
P3= 0 -102576923.076923 88834221.2266576
The secod Plane:
P1= 152763459.308716 -102576923.076923 0
P2= -102576923.076923 183536536.231793 -102576923.076923
P3= 0 -102576923.076923 91768268.1158967How to find the line of intersection between the following two planes and plot the intersected line on the same two planes?
The following points contain the following points:
The first plane:
P1 = 177668442.453315 -102576923.076923 0
P2 = -102576923.076923 177668442.453315 -102576923.076923
P3= 0 -102576923.076923 88834221.2266576
The secod Plane:
P1= 152763459.308716 -102576923.076923 0
P2= -102576923.076923 183536536.231793 -102576923.076923
P3= 0 -102576923.076923 91768268.1158967 How to find the line of intersection between the following two planes and plot the intersected line on the same two planes?
The following points contain the following points:
The first plane:
P1 = 177668442.453315 -102576923.076923 0
P2 = -102576923.076923 177668442.453315 -102576923.076923
P3= 0 -102576923.076923 88834221.2266576
The secod Plane:
P1= 152763459.308716 -102576923.076923 0
P2= -102576923.076923 183536536.231793 -102576923.076923
P3= 0 -102576923.076923 91768268.1158967 plane, calculus, mathematics, plot MATLAB Answers — New Questions
Screenshot of Edge after watching videos
See screenshot below. Is it a video cards problem or Edge problem. This happens when I click the X to get out of video and back to Edge. Lasts about 5-6 seconds then Edge is normal. No new programs installed or removed. Started two days ago.
See screenshot below. Is it a video cards problem or Edge problem. This happens when I click the X to get out of video and back to Edge. Lasts about 5-6 seconds then Edge is normal. No new programs installed or removed. Started two days ago. Read More
Cell formatting
I would like to apply some number formatting and add some text, let’s say, at the end of a cell. For instance, for the formatting code (with 4 sections):
[Red]General;[Green]General;[Blue]General;” USD” @
I would expect some colored values, any followed by USD text. This is not happening (the text part) !
Please help !
PS: I am not looking for an altenative solution, I would simple like to use what’s written in excel help:
Include a section for text entry If included, a text section is always the last section in the number format. Include an “at” character (@) in the section where you want to display any text that you type in the cell. If the @ character is omitted from the text section, text that you type will not be displayed. If you want to always display specific text characters with the typed text, enclose the additional text in double quotation marks (” “). For example, “gross receipts for “@
If the format does not include a text section, any non-numeric value that you type in a cell with that format applied is not affected by the format. In addition, the entire cell is converted to text.
I would like to apply some number formatting and add some text, let’s say, at the end of a cell. For instance, for the formatting code (with 4 sections):[Red]General;[Green]General;[Blue]General;” USD” @I would expect some colored values, any followed by USD text. This is not happening (the text part) !Please help !PS: I am not looking for an altenative solution, I would simple like to use what’s written in excel help:Include a section for text entry If included, a text section is always the last section in the number format. Include an “at” character (@) in the section where you want to display any text that you type in the cell. If the @ character is omitted from the text section, text that you type will not be displayed. If you want to always display specific text characters with the typed text, enclose the additional text in double quotation marks (” “). For example, “gross receipts for “@If the format does not include a text section, any non-numeric value that you type in a cell with that format applied is not affected by the format. In addition, the entire cell is converted to text. Read More
can anyone have MATLAB code for dual tier cluster based routing protocol for wireless sensor network or any basic code related to this
can anyone have MATLAB code for dual tier cluster based routing protocol for wireless sensor network or any basic code related to thiscan anyone have MATLAB code for dual tier cluster based routing protocol for wireless sensor network or any basic code related to this can anyone have MATLAB code for dual tier cluster based routing protocol for wireless sensor network or any basic code related to this mobile wsn routing protocol matlab code MATLAB Answers — New Questions
How to build complex DL 5G waveform with multiple UEs, Layers and Precoding
I’m looking for examples to build complex 5G DL waveform which includes multiple UEs with different RBs per user, different number of Layes per user and different Precoding (beamforming) per user.I’m looking for examples to build complex 5G DL waveform which includes multiple UEs with different RBs per user, different number of Layes per user and different Precoding (beamforming) per user. I’m looking for examples to build complex 5G DL waveform which includes multiple UEs with different RBs per user, different number of Layes per user and different Precoding (beamforming) per user. 5g MATLAB Answers — New Questions
A Hora e a Vez das Startups
É com imensa alegria que anunciamos que a Tistto, sob a liderança visionária da empreendedora Beatriz Duart, tornou-se a primeira startup liderada por uma mulher selecionada para apresentar seu modelo de negócio no Warmup Mulheres na IA, que será realizado no Cubo Itaú, em 17/07. Beatriz também será destaque no AI Summit Brasil, em 03/09! Se você deseja levar sua startup com Inteligência Artificial ao próximo nível, o AI Summit Brasil é o lugar ideal! Este é o momento de destacar sua inovação, fazer conexões que transformarão o futuro e estar frente a frente com os gigantes da indústria, investidores visionários e especialistas em tecnologia que moldam o amanhã. No AI Summit Brasil, sua startup não será apenas mais uma – ela será a protagonista, a força motriz em um universo de oportunidades. Junte-se às startups TOP como Tistto, Nuvia e Tech4Humans e faça parte deste evento transformador. Não perca a oportunidade única de fazer história e elevar sua startup a novos patamares. Inscreva-se agora: https://aisummit.org.br/ Muzy Jorge, MSc. Presidente AI Summit Brasil INSTITUTO VALOR #AISummitBrasil #InstitutoValor #Inovação #IA #InteligênciaArtificial #AISummitPodcast #AISummitWarmup #MulheresNaIA
É com imensa alegria que anunciamos que a Tistto, sob a liderança visionária da empreendedora Beatriz Duart, tornou-se a primeira startup liderada por uma mulher selecionada para apresentar seu modelo de negócio no Warmup Mulheres na IA, que será realizado no Cubo Itaú, em 17/07. Beatriz também será destaque no AI Summit Brasil, em 03/09! Se você deseja levar sua startup com Inteligência Artificial ao próximo nível, o AI Summit Brasil é o lugar ideal! Este é o momento de destacar sua inovação, fazer conexões que transformarão o futuro e estar frente a frente com os gigantes da indústria, investidores visionários e especialistas em tecnologia que moldam o amanhã. No AI Summit Brasil, sua startup não será apenas mais uma – ela será a protagonista, a força motriz em um universo de oportunidades. Junte-se às startups TOP como Tistto, Nuvia e Tech4Humans e faça parte deste evento transformador. Não perca a oportunidade única de fazer história e elevar sua startup a novos patamares. Inscreva-se agora: https://aisummit.org.br/ Muzy Jorge, MSc. Presidente AI Summit Brasil INSTITUTO VALOR #AISummitBrasil #InstitutoValor #Inovação #IA #InteligênciaArtificial #AISummitPodcast #AISummitWarmup #MulheresNaIA Read More
All bookings disappeared/ no more staff member
I wanted to create a booking for one of my customers and noticed that all of my bookings (past and upcoming) vanished. Additionally, there are no longer any staff members shown. As a self-employed individual, only my name normally shows. However, the complete list with customers and business information etc. is still accessible.
When I create a new booking, the customer does receive a confirmation, but it does not show up in my agenda.
Has there been a modification following an update, or is there an issue of some kind?
I wanted to create a booking for one of my customers and noticed that all of my bookings (past and upcoming) vanished. Additionally, there are no longer any staff members shown. As a self-employed individual, only my name normally shows. However, the complete list with customers and business information etc. is still accessible. When I create a new booking, the customer does receive a confirmation, but it does not show up in my agenda. Has there been a modification following an update, or is there an issue of some kind? Read More
Onedrive
Hello, I have a problem with my OneDrive. Because whenever I take a screenshot of my Samsung smartphone, the system automatically saves all screenshots. I even turned off the automatic sync in the settings of OneDrive, which it does not save automatically. Can you help me that it no longer automatically? I’m slowly desperate that you can’t turn it off? Thank you
Hello, I have a problem with my OneDrive. Because whenever I take a screenshot of my Samsung smartphone, the system automatically saves all screenshots. I even turned off the automatic sync in the settings of OneDrive, which it does not save automatically. Can you help me that it no longer automatically? I’m slowly desperate that you can’t turn it off? Thank you Read More
Derivation of noisy signal through Savitzky-Golay
I want to get an approximation of a noisy signal’s second derivative through the use of a Savitzky-Golay differentation matrix. The final goal is to (1) smooth out and (2) drastically downsample the initial signal without losing information. I was inspired for this idea by Jan’s post on https://nl.mathworks.com/matlabcentral/answers/1454924-downsample-data-adapively-intelligently where they used the gradient function to determine where the represented data has the strongest curvature and hence where it needs the most points.
The result is pretty much what I hoped for except for the edges of my domain where absent data is assumed to be zero which creates strong gradients across the width of the filter. This issue is not as impactful on the smoothing as it is on the derivation. In fact, function sgolayfilt satisfyingly corrects the edge effect from the straight up use of sgolay as explained in this https://nl.mathworks.com/help/signal/ref/sgolayfilt.html thread.
Then my problem is: how can I similarly resolve this effect on the approximated second derivative? I tried looking into the theory of this but it confuses me a little.
My current solution to the limitations of this filter was to equate the estimated derivative on these data points close to the edges to the closest value I was able to estimate properly. Here is the code I came up with so far:
%sgFilter – Adaptative downsampling using a Savitzky-Golay filter
%
% This MATLAB function uses a Savitzky-Golay differentiation filter in
% order to successively smooth out a signal x(t) and reduce its sample
% size down to n datapoints. An estimate of the 2nd derivative through
% the lens of the filter allows to map out the curvature of the signal
% without concern for the noise and helps identify hotspots needed for
% the accurate representation of the signal after downsampling.
%
% y filtered signal
% y(idx) filtered and sampled signal
% . . . .
% dt uniform step size
% order polynomial regression order
% window filter band width
%
% [y, idx] = sgFilter(x, dt, order, window, n)
function [y, idx] = sgFilter(x, dt, order, window, n)
% ———————————————————————–
% Savitzky-Golay differentiation matrices
[b, g] = sgolay(order, window);
m = (window – 1)/2;
% ———————————————————————–
% p-th order derivative estimates, i.e. 0: smooth and 2: 2nd derivative
dx = zeros(length(x), 2);
i = 0;
for p = [0, 2]
i = i + 1;
dx(:,i) = conv(x, factorial(p)/(-dt)^p * g(:, p + 1), ‘same’);
end
% ———————————————————————–
% Correction of the edge effect on smoothing
y = dx(:, 1); % Smoothed signal
y(1:m) = b(1:m, :)*x(1:window);
y(end – m + 1:end) = b(window – m + 1:window, :)*x(end – window + 1:end);
dy = dx(:, 2); % Smoothed signal’s derivative
dy(1:m) = dy(m + 1);
dy(end – m + 1:end) = dy(end – m);
% ———————————————————————–
% Adaptative downsampling, inspired from Jan at <https://nl.mathworks.com
% /matlabcentral/answers/1454924-downsample-data-adapively-intelligently>
% (17th May 2024).
if nargout > 1
sy = cumsum(abs(dy));
sy = sy + linspace(0, max(sy)/100, numel(sy)).’; % Monotonic increasing
idx = interp1(sy, 1:numel(sy), linspace(sy(1), sy(end), n), ‘nearest’);
end
And following is a test script I created with this function and the associated result:
% ————————————————————————-
% One should note that the success of this method is very dependent on the
% choice of polynomial regression order and window band width. In the
% particular case of periodic signals, the window should be wide enough to
% encompass periods with corresponding polynomial behaviour—e.g. a full
% sin(x) rotation from x to x + 2*pi cannot be represented accurately by a
% polynome of lower degree than 3, nor will it always be advantageous to
% have a degree higher than 3 due to Runge’s phenomenon. On this note, one
% should be conscious of the size of the window relative to the overall
% behaviour of the signal.
% ————————————————————————-
dt = 0.05;
t = (0:dt:20-1)’;
order = 3;
window = 51;
x = 5*sin(2*pi*0.2*t)+0.5*randn(size(t));
[y, idx] = sgFilter(x, dt, order, window, 60);
plot(t, x, ‘-k’)
hold on
plot(t, y, ‘-r’)
plot(t(idx), y(idx), ‘ro’)
hold off
legend(‘x’,’x (smoothed)’,’x (sampled)’)
As you can see, the current band width of the filter is approximately 2.5 long on the horizontal axis and half of that window is impacted by the edge effect with an overrepresentation close to t = 0 and an underrepresentation on the other end.I want to get an approximation of a noisy signal’s second derivative through the use of a Savitzky-Golay differentation matrix. The final goal is to (1) smooth out and (2) drastically downsample the initial signal without losing information. I was inspired for this idea by Jan’s post on https://nl.mathworks.com/matlabcentral/answers/1454924-downsample-data-adapively-intelligently where they used the gradient function to determine where the represented data has the strongest curvature and hence where it needs the most points.
The result is pretty much what I hoped for except for the edges of my domain where absent data is assumed to be zero which creates strong gradients across the width of the filter. This issue is not as impactful on the smoothing as it is on the derivation. In fact, function sgolayfilt satisfyingly corrects the edge effect from the straight up use of sgolay as explained in this https://nl.mathworks.com/help/signal/ref/sgolayfilt.html thread.
Then my problem is: how can I similarly resolve this effect on the approximated second derivative? I tried looking into the theory of this but it confuses me a little.
My current solution to the limitations of this filter was to equate the estimated derivative on these data points close to the edges to the closest value I was able to estimate properly. Here is the code I came up with so far:
%sgFilter – Adaptative downsampling using a Savitzky-Golay filter
%
% This MATLAB function uses a Savitzky-Golay differentiation filter in
% order to successively smooth out a signal x(t) and reduce its sample
% size down to n datapoints. An estimate of the 2nd derivative through
% the lens of the filter allows to map out the curvature of the signal
% without concern for the noise and helps identify hotspots needed for
% the accurate representation of the signal after downsampling.
%
% y filtered signal
% y(idx) filtered and sampled signal
% . . . .
% dt uniform step size
% order polynomial regression order
% window filter band width
%
% [y, idx] = sgFilter(x, dt, order, window, n)
function [y, idx] = sgFilter(x, dt, order, window, n)
% ———————————————————————–
% Savitzky-Golay differentiation matrices
[b, g] = sgolay(order, window);
m = (window – 1)/2;
% ———————————————————————–
% p-th order derivative estimates, i.e. 0: smooth and 2: 2nd derivative
dx = zeros(length(x), 2);
i = 0;
for p = [0, 2]
i = i + 1;
dx(:,i) = conv(x, factorial(p)/(-dt)^p * g(:, p + 1), ‘same’);
end
% ———————————————————————–
% Correction of the edge effect on smoothing
y = dx(:, 1); % Smoothed signal
y(1:m) = b(1:m, :)*x(1:window);
y(end – m + 1:end) = b(window – m + 1:window, :)*x(end – window + 1:end);
dy = dx(:, 2); % Smoothed signal’s derivative
dy(1:m) = dy(m + 1);
dy(end – m + 1:end) = dy(end – m);
% ———————————————————————–
% Adaptative downsampling, inspired from Jan at <https://nl.mathworks.com
% /matlabcentral/answers/1454924-downsample-data-adapively-intelligently>
% (17th May 2024).
if nargout > 1
sy = cumsum(abs(dy));
sy = sy + linspace(0, max(sy)/100, numel(sy)).’; % Monotonic increasing
idx = interp1(sy, 1:numel(sy), linspace(sy(1), sy(end), n), ‘nearest’);
end
And following is a test script I created with this function and the associated result:
% ————————————————————————-
% One should note that the success of this method is very dependent on the
% choice of polynomial regression order and window band width. In the
% particular case of periodic signals, the window should be wide enough to
% encompass periods with corresponding polynomial behaviour—e.g. a full
% sin(x) rotation from x to x + 2*pi cannot be represented accurately by a
% polynome of lower degree than 3, nor will it always be advantageous to
% have a degree higher than 3 due to Runge’s phenomenon. On this note, one
% should be conscious of the size of the window relative to the overall
% behaviour of the signal.
% ————————————————————————-
dt = 0.05;
t = (0:dt:20-1)’;
order = 3;
window = 51;
x = 5*sin(2*pi*0.2*t)+0.5*randn(size(t));
[y, idx] = sgFilter(x, dt, order, window, 60);
plot(t, x, ‘-k’)
hold on
plot(t, y, ‘-r’)
plot(t(idx), y(idx), ‘ro’)
hold off
legend(‘x’,’x (smoothed)’,’x (sampled)’)
As you can see, the current band width of the filter is approximately 2.5 long on the horizontal axis and half of that window is impacted by the edge effect with an overrepresentation close to t = 0 and an underrepresentation on the other end. I want to get an approximation of a noisy signal’s second derivative through the use of a Savitzky-Golay differentation matrix. The final goal is to (1) smooth out and (2) drastically downsample the initial signal without losing information. I was inspired for this idea by Jan’s post on https://nl.mathworks.com/matlabcentral/answers/1454924-downsample-data-adapively-intelligently where they used the gradient function to determine where the represented data has the strongest curvature and hence where it needs the most points.
The result is pretty much what I hoped for except for the edges of my domain where absent data is assumed to be zero which creates strong gradients across the width of the filter. This issue is not as impactful on the smoothing as it is on the derivation. In fact, function sgolayfilt satisfyingly corrects the edge effect from the straight up use of sgolay as explained in this https://nl.mathworks.com/help/signal/ref/sgolayfilt.html thread.
Then my problem is: how can I similarly resolve this effect on the approximated second derivative? I tried looking into the theory of this but it confuses me a little.
My current solution to the limitations of this filter was to equate the estimated derivative on these data points close to the edges to the closest value I was able to estimate properly. Here is the code I came up with so far:
%sgFilter – Adaptative downsampling using a Savitzky-Golay filter
%
% This MATLAB function uses a Savitzky-Golay differentiation filter in
% order to successively smooth out a signal x(t) and reduce its sample
% size down to n datapoints. An estimate of the 2nd derivative through
% the lens of the filter allows to map out the curvature of the signal
% without concern for the noise and helps identify hotspots needed for
% the accurate representation of the signal after downsampling.
%
% y filtered signal
% y(idx) filtered and sampled signal
% . . . .
% dt uniform step size
% order polynomial regression order
% window filter band width
%
% [y, idx] = sgFilter(x, dt, order, window, n)
function [y, idx] = sgFilter(x, dt, order, window, n)
% ———————————————————————–
% Savitzky-Golay differentiation matrices
[b, g] = sgolay(order, window);
m = (window – 1)/2;
% ———————————————————————–
% p-th order derivative estimates, i.e. 0: smooth and 2: 2nd derivative
dx = zeros(length(x), 2);
i = 0;
for p = [0, 2]
i = i + 1;
dx(:,i) = conv(x, factorial(p)/(-dt)^p * g(:, p + 1), ‘same’);
end
% ———————————————————————–
% Correction of the edge effect on smoothing
y = dx(:, 1); % Smoothed signal
y(1:m) = b(1:m, :)*x(1:window);
y(end – m + 1:end) = b(window – m + 1:window, :)*x(end – window + 1:end);
dy = dx(:, 2); % Smoothed signal’s derivative
dy(1:m) = dy(m + 1);
dy(end – m + 1:end) = dy(end – m);
% ———————————————————————–
% Adaptative downsampling, inspired from Jan at <https://nl.mathworks.com
% /matlabcentral/answers/1454924-downsample-data-adapively-intelligently>
% (17th May 2024).
if nargout > 1
sy = cumsum(abs(dy));
sy = sy + linspace(0, max(sy)/100, numel(sy)).’; % Monotonic increasing
idx = interp1(sy, 1:numel(sy), linspace(sy(1), sy(end), n), ‘nearest’);
end
And following is a test script I created with this function and the associated result:
% ————————————————————————-
% One should note that the success of this method is very dependent on the
% choice of polynomial regression order and window band width. In the
% particular case of periodic signals, the window should be wide enough to
% encompass periods with corresponding polynomial behaviour—e.g. a full
% sin(x) rotation from x to x + 2*pi cannot be represented accurately by a
% polynome of lower degree than 3, nor will it always be advantageous to
% have a degree higher than 3 due to Runge’s phenomenon. On this note, one
% should be conscious of the size of the window relative to the overall
% behaviour of the signal.
% ————————————————————————-
dt = 0.05;
t = (0:dt:20-1)’;
order = 3;
window = 51;
x = 5*sin(2*pi*0.2*t)+0.5*randn(size(t));
[y, idx] = sgFilter(x, dt, order, window, 60);
plot(t, x, ‘-k’)
hold on
plot(t, y, ‘-r’)
plot(t(idx), y(idx), ‘ro’)
hold off
legend(‘x’,’x (smoothed)’,’x (sampled)’)
As you can see, the current band width of the filter is approximately 2.5 long on the horizontal axis and half of that window is impacted by the edge effect with an overrepresentation close to t = 0 and an underrepresentation on the other end. smoothing, derivative, downsampling MATLAB Answers — New Questions
Email the selected Cells
I need help in finding a solution to send email
automate feature is disabled so no idea what should I do
email content
To : W1
Subject: S1
Body : A2:K151
There is no CC
Please help,
My list seperator is | (pipe) instead of , (comma)
I tried this formula but its not working
=Hyperlink(“mailto:”&W1&subject=”&S1&”&body=”&A2:K151|”Email”)
Kindly help
I need help in finding a solution to send emailautomate feature is disabled so no idea what should I doemail contentTo : W1Subject: S1Body : A2:K151There is no CCPlease help,My list seperator is | (pipe) instead of , (comma) I tried this formula but its not working=Hyperlink(“mailto:”&W1&subject=”&S1&”&body=”&A2:K151|”Email”) Kindly help Read More
Rapport d’accompagnement des élèves aux oraux
Décrive moi un rapport d’accompagnement des élèves CPGE aux oraux des écoles Polytechnique, Centrale et Mines pont de Paris.
Décrive moi un rapport d’accompagnement des élèves CPGE aux oraux des écoles Polytechnique, Centrale et Mines pont de Paris. Read More
gitignore configuration for Mesh projects
I’ve noticed that some files are created in the Assets folder during the build. Is it safe to put those folders to gitignore to not keep them in the repo (they can be like 50-100MB files)?
Do you have any other advice on which files can also be ignored?
I’ve noticed that some files are created in the Assets folder during the build. Is it safe to put those folders to gitignore to not keep them in the repo (they can be like 50-100MB files)?Do you have any other advice on which files can also be ignored? Read More