Month: July 2024
Removing drift from EMG signal
i want to remove the drift from my emg signal that i obtained. i am using the following script
the original emg looks like this:
with the scipt above i get the following detrend:
u can see that the drift isnt completely removed, can anyone see what i am doing wrong or what i can change in my script to get the perfect result around y=0
thanks in advance!i want to remove the drift from my emg signal that i obtained. i am using the following script
the original emg looks like this:
with the scipt above i get the following detrend:
u can see that the drift isnt completely removed, can anyone see what i am doing wrong or what i can change in my script to get the perfect result around y=0
thanks in advance! i want to remove the drift from my emg signal that i obtained. i am using the following script
the original emg looks like this:
with the scipt above i get the following detrend:
u can see that the drift isnt completely removed, can anyone see what i am doing wrong or what i can change in my script to get the perfect result around y=0
thanks in advance! removing drift MATLAB Answers — New Questions
Error using trainNetwork (line 191) Too many input arguments.
Hello, i am trying to code an automatic detection of alzheimer from EEG signals but my code has an error when using trainNetwork. It worked perfectely with a SVM but doesn’t with a CNN. I tried looking online but nothing seems too work. I got this error :
Error using trainNetwork (line 191)
Too many input arguments.
Error in CNN (line 178)
net = trainNetwork(X_train, y_train, layers, options);
Caused by:
Error using gather
Too many input arguments.
Does anyone have an idea. Here is the part of my code that produce the CNN :
X = all_features{:, 1:end-1}; % Use parentheses () for table indexing
y = all_features.Label;
y = categorical(y);
disp([‘Feature matrix dimensions: ‘, num2str(size(X))]);
disp([‘Labels vector dimensions: ‘, num2str(size(y))]);
X = zscore(X);
numFeatures = size(X, 2);
numObservations = size(X, 1);
X = reshape(X, [numObservations, numFeatures, 1, 1]); % Reshape for CNN
layers = [
imageInputLayer([numFeatures 1 1])
convolution2dLayer([3 1], 8, ‘Padding’, ‘same’)
batchNormalizationLayer
reluLayer
maxPooling2dLayer([2 1], ‘Stride’, 2)
convolution2dLayer([3 1], 16, ‘Padding’, ‘same’)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
options = trainingOptions(‘adam’, …
‘MaxEpochs’, 30, …
‘MiniBatchSize’, 16, …
‘InitialLearnRate’, 0.001, …
‘ValidationFrequency’, 10, …
‘Verbose’, false, …
‘Plots’, ‘training-progress’);
% 5-Fold Cross-Validation
cv = cvpartition(y, ‘KFold’, 5, ‘Stratify’, true);
accuracies = zeros(cv.NumTestSets, 1);
confusion_matrices = cell(cv.NumTestSets, 1);
for k = 1:cv.NumTestSets
train_idx = training(cv, k);
test_idx = test(cv, k);
X_train = X(train_idx, :, :, :);
y_train = y(train_idx);
X_test = X(test_idx, :, :, :);
y_test = y(test_idx);
net = trainNetwork(X_train, y_train, layers, options);
y_pred = classify(net, X_test);
confusion_matrices{k} = confusionmat(y_test, y_pred);
cm = confusion_matrices{k};
accuracies(k) = sum(diag(cm)) / sum(cm(:));
end
mean_accuracy = mean(accuracies);
fprintf(‘Mean Accuracy across 5 folds: %.2f%%n’, mean_accuracy * 100);
save(‘eeg_cnn_classifier_cv.mat’, ‘net’);
disp(‘Confusion Matrices for each fold:’);
for k = 1:cv.NumTestSets
disp([‘Fold ‘, num2str(k), ‘:’]);
disp(confusion_matrices{k});
endHello, i am trying to code an automatic detection of alzheimer from EEG signals but my code has an error when using trainNetwork. It worked perfectely with a SVM but doesn’t with a CNN. I tried looking online but nothing seems too work. I got this error :
Error using trainNetwork (line 191)
Too many input arguments.
Error in CNN (line 178)
net = trainNetwork(X_train, y_train, layers, options);
Caused by:
Error using gather
Too many input arguments.
Does anyone have an idea. Here is the part of my code that produce the CNN :
X = all_features{:, 1:end-1}; % Use parentheses () for table indexing
y = all_features.Label;
y = categorical(y);
disp([‘Feature matrix dimensions: ‘, num2str(size(X))]);
disp([‘Labels vector dimensions: ‘, num2str(size(y))]);
X = zscore(X);
numFeatures = size(X, 2);
numObservations = size(X, 1);
X = reshape(X, [numObservations, numFeatures, 1, 1]); % Reshape for CNN
layers = [
imageInputLayer([numFeatures 1 1])
convolution2dLayer([3 1], 8, ‘Padding’, ‘same’)
batchNormalizationLayer
reluLayer
maxPooling2dLayer([2 1], ‘Stride’, 2)
convolution2dLayer([3 1], 16, ‘Padding’, ‘same’)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
options = trainingOptions(‘adam’, …
‘MaxEpochs’, 30, …
‘MiniBatchSize’, 16, …
‘InitialLearnRate’, 0.001, …
‘ValidationFrequency’, 10, …
‘Verbose’, false, …
‘Plots’, ‘training-progress’);
% 5-Fold Cross-Validation
cv = cvpartition(y, ‘KFold’, 5, ‘Stratify’, true);
accuracies = zeros(cv.NumTestSets, 1);
confusion_matrices = cell(cv.NumTestSets, 1);
for k = 1:cv.NumTestSets
train_idx = training(cv, k);
test_idx = test(cv, k);
X_train = X(train_idx, :, :, :);
y_train = y(train_idx);
X_test = X(test_idx, :, :, :);
y_test = y(test_idx);
net = trainNetwork(X_train, y_train, layers, options);
y_pred = classify(net, X_test);
confusion_matrices{k} = confusionmat(y_test, y_pred);
cm = confusion_matrices{k};
accuracies(k) = sum(diag(cm)) / sum(cm(:));
end
mean_accuracy = mean(accuracies);
fprintf(‘Mean Accuracy across 5 folds: %.2f%%n’, mean_accuracy * 100);
save(‘eeg_cnn_classifier_cv.mat’, ‘net’);
disp(‘Confusion Matrices for each fold:’);
for k = 1:cv.NumTestSets
disp([‘Fold ‘, num2str(k), ‘:’]);
disp(confusion_matrices{k});
end Hello, i am trying to code an automatic detection of alzheimer from EEG signals but my code has an error when using trainNetwork. It worked perfectely with a SVM but doesn’t with a CNN. I tried looking online but nothing seems too work. I got this error :
Error using trainNetwork (line 191)
Too many input arguments.
Error in CNN (line 178)
net = trainNetwork(X_train, y_train, layers, options);
Caused by:
Error using gather
Too many input arguments.
Does anyone have an idea. Here is the part of my code that produce the CNN :
X = all_features{:, 1:end-1}; % Use parentheses () for table indexing
y = all_features.Label;
y = categorical(y);
disp([‘Feature matrix dimensions: ‘, num2str(size(X))]);
disp([‘Labels vector dimensions: ‘, num2str(size(y))]);
X = zscore(X);
numFeatures = size(X, 2);
numObservations = size(X, 1);
X = reshape(X, [numObservations, numFeatures, 1, 1]); % Reshape for CNN
layers = [
imageInputLayer([numFeatures 1 1])
convolution2dLayer([3 1], 8, ‘Padding’, ‘same’)
batchNormalizationLayer
reluLayer
maxPooling2dLayer([2 1], ‘Stride’, 2)
convolution2dLayer([3 1], 16, ‘Padding’, ‘same’)
batchNormalizationLayer
reluLayer
fullyConnectedLayer(2)
softmaxLayer
classificationLayer];
options = trainingOptions(‘adam’, …
‘MaxEpochs’, 30, …
‘MiniBatchSize’, 16, …
‘InitialLearnRate’, 0.001, …
‘ValidationFrequency’, 10, …
‘Verbose’, false, …
‘Plots’, ‘training-progress’);
% 5-Fold Cross-Validation
cv = cvpartition(y, ‘KFold’, 5, ‘Stratify’, true);
accuracies = zeros(cv.NumTestSets, 1);
confusion_matrices = cell(cv.NumTestSets, 1);
for k = 1:cv.NumTestSets
train_idx = training(cv, k);
test_idx = test(cv, k);
X_train = X(train_idx, :, :, :);
y_train = y(train_idx);
X_test = X(test_idx, :, :, :);
y_test = y(test_idx);
net = trainNetwork(X_train, y_train, layers, options);
y_pred = classify(net, X_test);
confusion_matrices{k} = confusionmat(y_test, y_pred);
cm = confusion_matrices{k};
accuracies(k) = sum(diag(cm)) / sum(cm(:));
end
mean_accuracy = mean(accuracies);
fprintf(‘Mean Accuracy across 5 folds: %.2f%%n’, mean_accuracy * 100);
save(‘eeg_cnn_classifier_cv.mat’, ‘net’);
disp(‘Confusion Matrices for each fold:’);
for k = 1:cv.NumTestSets
disp([‘Fold ‘, num2str(k), ‘:’]);
disp(confusion_matrices{k});
end cnn, machine learning, deep learning MATLAB Answers — New Questions
Character garble
Hello Teams!
The database fields use the varchar type, When I insert the character ‘⅜’, It shows a ‘?’.
How can I solve this problem? Thanks!
Regards!
Hello Teams! The database fields use the varchar type, When I insert the character ‘⅜’, It shows a ‘?’.How can I solve this problem? Thanks! Regards! Read More
Disappearing Excel cells
Hi all,
I have a spreadsheet which has 5-600 rows data. when i scroll down or up the cells data disappears and then i click on other cells and scroll again to make the data visible, this is a hectic every time i have to do it. kindly let me know the solution.
Note: i am using new dell laptop latitude 3440 with 512 GB SSD and 16GB RAM
thanks in advance.
Hi all, I have a spreadsheet which has 5-600 rows data. when i scroll down or up the cells data disappears and then i click on other cells and scroll again to make the data visible, this is a hectic every time i have to do it. kindly let me know the solution. Note: i am using new dell laptop latitude 3440 with 512 GB SSD and 16GB RAM thanks in advance. Read More
ADF to Purview created connection gets disconnected
I have followed up the MS instructions to create ADF Purview connection but after a while it gets disconnected or the status changes to ‘unknown’ instead of ‘connected’. How should I fix the issue? It happens with multiple ADF workspaces
I have followed up the MS instructions to create ADF Purview connection but after a while it gets disconnected or the status changes to ‘unknown’ instead of ‘connected’. How should I fix the issue? It happens with multiple ADF workspaces Read More
How to set SensitiveInfoDetectionIsIncluded to true so CloudAppEvents schema returns data
Hello,
I have few incidents created for my purview policies and i see the incidents and alerts in Security.microsoft.com
i am running the following simple advance hunting query
I understand that as long as this is false, i cannot see the forensic data (violating data) for the incident.
“RawEventData”: {
“@odata.type”: “#microsoft.graph.security.dynamicColumnValue”,
“CreationTime”: “2024-07-22T12:46:33.0000000Z”,
“Id”: “fff346cc-***”,
“IncidentId”: “89630849-***”,
“ObjectId”: “<*.*.PROD.OUTLOOK.COM>”,
“Operation”: “DlpRuleMatch”,
“OrganizationId”: “***”,
“email address removed for privacy reasons”: “#Collection(String)”,
“PolicyDetails”: [
“{“PolicyId”:”2d7eb..”,”PolicyName”:”generate email incidents with block.”,”Rules”:[{“ActionParameters”:[“GenerateAlert:true”],”Actions”:[“BlockAccess”,”GenerateAlert”],”ConditionsMatched”:{“ConditionMatchedInNewScheme”:false,”OtherConditions”:[{“Name”:”From”,”Value”:”0f66…”}]},”ManagementRuleId”:”bbe..”,”RuleId”:”101e3f12-…”,”RuleMode”:”Enable”,”RuleName”:”Block emails with keyword”,”Severity”:”Medium”}]}”
],
“email address removed for privacy reasons”: “#Int64”,
“RecordType”: 13,
“SensitiveInfoDetectionIsIncluded”: false,
.
.
.
Hello,I have few incidents created for my purview policies and i see the incidents and alerts in Security.microsoft.com i am running the following simple advance hunting queryCloudAppEvents| where ActivityType == ‘Securityevent’ In the result i see “SensitiveInfoDetectionIsIncluded”: false, under RawEventDataI understand that as long as this is false, i cannot see the forensic data (violating data) for the incident. How can i set this value to true, so that i can get the forensic data. My goal is to use graph api with advance hunting to retrieve this data so that i can load it into my application (End user remediation) as a case and educate the users about the violation. “RawEventData”: {
“@odata.type”: “#microsoft.graph.security.dynamicColumnValue”,
“CreationTime”: “2024-07-22T12:46:33.0000000Z”,
“Id”: “fff346cc-***”,
“IncidentId”: “89630849-***”,
“ObjectId”: “<*.*.PROD.OUTLOOK.COM>”,
“Operation”: “DlpRuleMatch”,
“OrganizationId”: “***”,
“email address removed for privacy reasons”: “#Collection(String)”,
“PolicyDetails”: [
“{“PolicyId”:”2d7eb..”,”PolicyName”:”generate email incidents with block.”,”Rules”:[{“ActionParameters”:[“GenerateAlert:true”],”Actions”:[“BlockAccess”,”GenerateAlert”],”ConditionsMatched”:{“ConditionMatchedInNewScheme”:false,”OtherConditions”:[{“Name”:”From”,”Value”:”0f66…”}]},”ManagementRuleId”:”bbe..”,”RuleId”:”101e3f12-…”,”RuleMode”:”Enable”,”RuleName”:”Block emails with keyword”,”Severity”:”Medium”}]}”
],
“email address removed for privacy reasons”: “#Int64”,
“RecordType”: 13,
“SensitiveInfoDetectionIsIncluded”: false,
.
.
. Read More
Erase leftovers after windows recovery
Hello,
I want to make my 1 years old laptop to be as just got out of the box.
There is no built-in partition to restore it so I use the Windows 11 restore tool without saving my files and use the deep recovery.
Right now the laptop is in the initial windows 11 setup which is good. How do I make sure there is no leftovers files and folders that should be erase manually? I’ll do it with 3rd party software to browse the hard drive because I dont want to complete the initial setup.
Hello,I want to make my 1 years old laptop to be as just got out of the box.There is no built-in partition to restore it so I use the Windows 11 restore tool without saving my files and use the deep recovery.Right now the laptop is in the initial windows 11 setup which is good. How do I make sure there is no leftovers files and folders that should be erase manually? I’ll do it with 3rd party software to browse the hard drive because I dont want to complete the initial setup. Read More
How to Convert AVIF to PNG in Bulk on Windows 11?
Anyone knows about AVIF image format? I recently received several AVIF images from a colleague, and when I tried to open them using the default Photos app, it didn’t work. I even tried a few third-party image viewers, but none of them seemed to support AVIF.
I guess I need to convert Avif to PNG in bulk so that I can view and edit them without any issues. I’ve heard that some online tools and software can handle AVIF to PNG conversion, but I’m concerned about the potential loss of quality and the security risks associated with uploading files to random websites. Additionally, I’d prefer a solution that allows me to bulk convert multiple files at once, as I have quite a few images to process.
Anyone knows about AVIF image format? I recently received several AVIF images from a colleague, and when I tried to open them using the default Photos app, it didn’t work. I even tried a few third-party image viewers, but none of them seemed to support AVIF. I guess I need to convert Avif to PNG in bulk so that I can view and edit them without any issues. I’ve heard that some online tools and software can handle AVIF to PNG conversion, but I’m concerned about the potential loss of quality and the security risks associated with uploading files to random websites. Additionally, I’d prefer a solution that allows me to bulk convert multiple files at once, as I have quite a few images to process. Read More
How to average the columns within this cell array?
Hi, I have a deeply nested cell array of cells which contains a lot of doubles (C_512_eye_numeric). I am aiming to average the columns of the doubles column-wise. I cant seem to achieve this.
Can someone help?
Thanks!Hi, I have a deeply nested cell array of cells which contains a lot of doubles (C_512_eye_numeric). I am aiming to average the columns of the doubles column-wise. I cant seem to achieve this.
Can someone help?
Thanks! Hi, I have a deeply nested cell array of cells which contains a lot of doubles (C_512_eye_numeric). I am aiming to average the columns of the doubles column-wise. I cant seem to achieve this.
Can someone help?
Thanks! cell, cell array, doubles, matrix, average MATLAB Answers — New Questions
Windows Server 2025 Secured-core Server blog is live!
Attention Security community members! We’ve just published a Windows Server 2025 Secured-core blog. Explore the latest advancements in securing your servers and learn how Secured-core servers and Microsoft Defender for Cloud work together to help protect against modern threats!
Windows Server 2025 Secured-core Server – Microsoft Community Hub
Attention Security community members! We’ve just published a Windows Server 2025 Secured-core blog. Explore the latest advancements in securing your servers and learn how Secured-core servers and Microsoft Defender for Cloud work together to help protect against modern threats!
Windows Server 2025 Secured-core Server – Microsoft Community Hub Read More
KB5040525 activates BitLock without user’s permission
Hello everyone!
When my laptop received an update named KB5040525, after my laptop had installed it, the windows started and I found out my D Drive was locked by BitLock without my permission.
To solve this problem, I uninstalled the package, and I was able to use the drive again.
This has happened twice and my laptop has kept reinstalling it. How to prevent this to happen again and I am still able to update mine with other useful packages?
Why does this package act like a ransomeware without a ransome?
Thank you for reading my post and providing helps!
Regards,
Quoc Si
Hello everyone! When my laptop received an update named KB5040525, after my laptop had installed it, the windows started and I found out my D Drive was locked by BitLock without my permission.To solve this problem, I uninstalled the package, and I was able to use the drive again. This has happened twice and my laptop has kept reinstalling it. How to prevent this to happen again and I am still able to update mine with other useful packages? Why does this package act like a ransomeware without a ransome? Thank you for reading my post and providing helps! Regards,Quoc Si Read More
Exchange 2019 Distribution group creation from ECP appending numbers
When an admin uses the ECP to create a group, the group is created with a set of numbers appended to the end of the name.
Example: New Group Name = “Test-Group” The group will be named “Test-Group-1-207130138”
This is due to a group not being created with the SamAccountName. There isn’t an option in the ECP to specify the SamAccountName.
Can this please be reverted back to how it functioned in prior installments of exchange?
When an admin uses the ECP to create a group, the group is created with a set of numbers appended to the end of the name.Example: New Group Name = “Test-Group” The group will be named “Test-Group-1-207130138″This is due to a group not being created with the SamAccountName. There isn’t an option in the ECP to specify the SamAccountName. Can this please be reverted back to how it functioned in prior installments of exchange? Read More
Any way to bulk convert opus to mp3 on Windows PC?
Hi everyone,
I’ve recently transferred hundreds of audio files in the .opus format from my Discord and Skype apps to my Windows 11 laptop. Unfortunately, I’ve discovered that these files won’t play on my computer, which is causing quite a bit of frustration. I understand that .opus is a format that’s not widely supported on many devices and media players, especially on Windows.
I am looking for a reliable way to bulk convert opus files to MP3 so that I can play them without any issues. Given the volume of files I need to convert, I’m hoping to find a solution that can handle batch processing to save time. I’m open to using software tools or command-line utilities, as long as the process is straightforward and doesn’t require too many steps.
Hi everyone, I’ve recently transferred hundreds of audio files in the .opus format from my Discord and Skype apps to my Windows 11 laptop. Unfortunately, I’ve discovered that these files won’t play on my computer, which is causing quite a bit of frustration. I understand that .opus is a format that’s not widely supported on many devices and media players, especially on Windows. I am looking for a reliable way to bulk convert opus files to MP3 so that I can play them without any issues. Given the volume of files I need to convert, I’m hoping to find a solution that can handle batch processing to save time. I’m open to using software tools or command-line utilities, as long as the process is straightforward and doesn’t require too many steps. Read More
Append query using a table created from a query
I’m trying to create an Append Query (i.e. query 2) utilising table A and table B. Table B is the result from another query (query 1) in this workbook. Query 1 utilises two tables.
Trouble is I can’t see this table in the query 2 dialogue box. How can I make table B available for the new query 2?
I’m trying to create an Append Query (i.e. query 2) utilising table A and table B. Table B is the result from another query (query 1) in this workbook. Query 1 utilises two tables. Trouble is I can’t see this table in the query 2 dialogue box. How can I make table B available for the new query 2? Read More
Oldest Build supported by Microsoft Defender for Endpoint
Hi everyone,
I have looked into the minimum OS supported by Microsoft defender, however the build versions of the OS are not indicated in the documentation. Can anyone confirm what the oldest build version of Windows 10 is supported by Microsoft Defender?
Thank you all!
Hi everyone,I have looked into the minimum OS supported by Microsoft defender, however the build versions of the OS are not indicated in the documentation. Can anyone confirm what the oldest build version of Windows 10 is supported by Microsoft Defender?Thank you all! Read More
do-while in parallel
Good morning:
I have a code in C# Framework 4.8 that has a rather heavy do-while. I would like to know if there is a way to run it in parallel like for or foreach, which have their parallel versions.
Thanks
Good morning:I have a code in C# Framework 4.8 that has a rather heavy do-while. I would like to know if there is a way to run it in parallel like for or foreach, which have their parallel versions.Thanks Read More
Can you recover deleted files after emptying the recycle bin?
I recently encountered a problem where I accidentally emptied my Recycle Bin on my Windows 11 PC, and lost several important files that I hadn’t intended to delete. I understand that once the Recycle Bin is emptied, the files aren’t easily recoverable, but I’m hoping there might still be a way to get them back. Has anyone else experienced this issue and successfully recover deleted files after emptying the recycle bin?
I’ve read that it might be possible to recover deleted files using specialized data recovery software. If anyone has recommendations for reliable tools or methods that can help retrieve files after they’ve been permanently deleted, I would greatly appreciate your advice.
I recently encountered a problem where I accidentally emptied my Recycle Bin on my Windows 11 PC, and lost several important files that I hadn’t intended to delete. I understand that once the Recycle Bin is emptied, the files aren’t easily recoverable, but I’m hoping there might still be a way to get them back. Has anyone else experienced this issue and successfully recover deleted files after emptying the recycle bin? I’ve read that it might be possible to recover deleted files using specialized data recovery software. If anyone has recommendations for reliable tools or methods that can help retrieve files after they’ve been permanently deleted, I would greatly appreciate your advice. Read More
AVD with HP ThinPro(linux) – problems with USB and big files
Hello everyone,
we use HP ThinClients with ThinPro 8.1 SP3 to connect to Microsoft AVD.
If we try to connect USB-Sticks oder external USB-Drives, we have a lot of Problems.
Big USB-Drives like 1TB would not be shown in AVD-File-Explorer.
Smaler USB-Sticks where shown, but if we try to move big files, over 100 MB, the complete AVD-Session breaks.
Does anyone have information about this, or how to make this going?
Many thanks for your help.
Best regards
Thomas
Hello everyone,we use HP ThinClients with ThinPro 8.1 SP3 to connect to Microsoft AVD.If we try to connect USB-Sticks oder external USB-Drives, we have a lot of Problems.Big USB-Drives like 1TB would not be shown in AVD-File-Explorer.Smaler USB-Sticks where shown, but if we try to move big files, over 100 MB, the complete AVD-Session breaks.Does anyone have information about this, or how to make this going?Many thanks for your help.Best regardsThomas Read More
How Do I Fix QBCF_Monitor Service not running on this computer Issue?
How can I resolve the issue with QBCF-Monitor Service not running on my computer? I’ve tried restarting the computer and checking the service status, but it still won’t start. Are there specific troubleshooting steps or solutions I should follow to fix this problem?
How can I resolve the issue with QBCF-Monitor Service not running on my computer? I’ve tried restarting the computer and checking the service status, but it still won’t start. Are there specific troubleshooting steps or solutions I should follow to fix this problem? Read More
How to save a variable from workspace into a .mat file, but the variable obtains value from a for loop?
I have this code and i want to save the variable x from workspace into a file clc;
clear;
close all;
% Parameters
sampling_frequency = 1000; % Sampling frequency in Hz
duration = 5; % Duration of signal acquisition in seconds
num_samples = sampling_frequency * duration;
% Initialize variables
time = (0:num_samples-1) / sampling_frequency;
x = zeros(1, num_samples);
% Connect to Arduino
a = arduino();
% Bandpass filter parameters
low_cutoff_frequency = 6; % Low cutoff frequency in Hz
high_cutoff_frequency = 400; % High cutoff frequency in Hz
% Design the bandpass filter
[b, a_filter] = butter(2, [low_cutoff_frequency, high_cutoff_frequency] / (sampling_frequency / 2), ‘bandpass’); %Normalized between [0 1]
% Plot for real-time visualization of raw signal
figure(‘Name’, ‘Real-Time Raw EMG Signal’);
h_raw = plot(nan, nan); % Initialize plot with NaN
grid on;
title(‘Real-Time Raw EMG Signal’);
xlabel(‘Time (s)’);
ylabel(‘Voltage (V)’);
xlim([0, duration]); % Adjust xlim as needed
ylim([0, 5]); % Adjust ylim according to expected voltage range
% Plot for real-time visualization of filtered signal
figure(‘Name’, ‘Real-Time Filtered EMG Signal’);
h_filtered = plot(nan, nan); % Initialize plot with NaN
grid on;
title(‘Real-Time Filtered EMG Signal’);
xlabel(‘Time (s)’);
ylabel(‘Voltage (V)’);
xlim([0, duration]); % Adjust xlim as needed
ylim([0, 5]); % Adjust ylim according to expected voltage range
% Start loop to acquire signal
for i = 1:num_samples
% Read voltage
raw_voltage = readVoltage(a, ‘A0’);
% Store raw voltage
x(i) = raw_voltage;
% Apply bandpass filter to the signal up to current point if enough data points are collected
if i >= 25
filtered_signal = filtfilt(b, a_filter, x(1:i));
% Remove DC offset by subtracting the mean of the filtered signal
filtered_signal = filtered_signal – mean(filtered_signal);
% Update plot for filtered signal
set(h_filtered, ‘YData’, filtered_signal, ‘XData’, time(1:i));
end
% Update plot for raw signal
set(h_raw, ‘YData’, x(1:i), ‘XData’, time(1:i));
drawnow;
end
save(‘EMG_data.mat’, ‘x’,);
It doesn’t create the .mat file and I suppose the problem is that i stop the iteration very early. But I want to save any values that are obtained until any iteration. How can I fix that?I have this code and i want to save the variable x from workspace into a file clc;
clear;
close all;
% Parameters
sampling_frequency = 1000; % Sampling frequency in Hz
duration = 5; % Duration of signal acquisition in seconds
num_samples = sampling_frequency * duration;
% Initialize variables
time = (0:num_samples-1) / sampling_frequency;
x = zeros(1, num_samples);
% Connect to Arduino
a = arduino();
% Bandpass filter parameters
low_cutoff_frequency = 6; % Low cutoff frequency in Hz
high_cutoff_frequency = 400; % High cutoff frequency in Hz
% Design the bandpass filter
[b, a_filter] = butter(2, [low_cutoff_frequency, high_cutoff_frequency] / (sampling_frequency / 2), ‘bandpass’); %Normalized between [0 1]
% Plot for real-time visualization of raw signal
figure(‘Name’, ‘Real-Time Raw EMG Signal’);
h_raw = plot(nan, nan); % Initialize plot with NaN
grid on;
title(‘Real-Time Raw EMG Signal’);
xlabel(‘Time (s)’);
ylabel(‘Voltage (V)’);
xlim([0, duration]); % Adjust xlim as needed
ylim([0, 5]); % Adjust ylim according to expected voltage range
% Plot for real-time visualization of filtered signal
figure(‘Name’, ‘Real-Time Filtered EMG Signal’);
h_filtered = plot(nan, nan); % Initialize plot with NaN
grid on;
title(‘Real-Time Filtered EMG Signal’);
xlabel(‘Time (s)’);
ylabel(‘Voltage (V)’);
xlim([0, duration]); % Adjust xlim as needed
ylim([0, 5]); % Adjust ylim according to expected voltage range
% Start loop to acquire signal
for i = 1:num_samples
% Read voltage
raw_voltage = readVoltage(a, ‘A0’);
% Store raw voltage
x(i) = raw_voltage;
% Apply bandpass filter to the signal up to current point if enough data points are collected
if i >= 25
filtered_signal = filtfilt(b, a_filter, x(1:i));
% Remove DC offset by subtracting the mean of the filtered signal
filtered_signal = filtered_signal – mean(filtered_signal);
% Update plot for filtered signal
set(h_filtered, ‘YData’, filtered_signal, ‘XData’, time(1:i));
end
% Update plot for raw signal
set(h_raw, ‘YData’, x(1:i), ‘XData’, time(1:i));
drawnow;
end
save(‘EMG_data.mat’, ‘x’,);
It doesn’t create the .mat file and I suppose the problem is that i stop the iteration very early. But I want to save any values that are obtained until any iteration. How can I fix that? I have this code and i want to save the variable x from workspace into a file clc;
clear;
close all;
% Parameters
sampling_frequency = 1000; % Sampling frequency in Hz
duration = 5; % Duration of signal acquisition in seconds
num_samples = sampling_frequency * duration;
% Initialize variables
time = (0:num_samples-1) / sampling_frequency;
x = zeros(1, num_samples);
% Connect to Arduino
a = arduino();
% Bandpass filter parameters
low_cutoff_frequency = 6; % Low cutoff frequency in Hz
high_cutoff_frequency = 400; % High cutoff frequency in Hz
% Design the bandpass filter
[b, a_filter] = butter(2, [low_cutoff_frequency, high_cutoff_frequency] / (sampling_frequency / 2), ‘bandpass’); %Normalized between [0 1]
% Plot for real-time visualization of raw signal
figure(‘Name’, ‘Real-Time Raw EMG Signal’);
h_raw = plot(nan, nan); % Initialize plot with NaN
grid on;
title(‘Real-Time Raw EMG Signal’);
xlabel(‘Time (s)’);
ylabel(‘Voltage (V)’);
xlim([0, duration]); % Adjust xlim as needed
ylim([0, 5]); % Adjust ylim according to expected voltage range
% Plot for real-time visualization of filtered signal
figure(‘Name’, ‘Real-Time Filtered EMG Signal’);
h_filtered = plot(nan, nan); % Initialize plot with NaN
grid on;
title(‘Real-Time Filtered EMG Signal’);
xlabel(‘Time (s)’);
ylabel(‘Voltage (V)’);
xlim([0, duration]); % Adjust xlim as needed
ylim([0, 5]); % Adjust ylim according to expected voltage range
% Start loop to acquire signal
for i = 1:num_samples
% Read voltage
raw_voltage = readVoltage(a, ‘A0’);
% Store raw voltage
x(i) = raw_voltage;
% Apply bandpass filter to the signal up to current point if enough data points are collected
if i >= 25
filtered_signal = filtfilt(b, a_filter, x(1:i));
% Remove DC offset by subtracting the mean of the filtered signal
filtered_signal = filtered_signal – mean(filtered_signal);
% Update plot for filtered signal
set(h_filtered, ‘YData’, filtered_signal, ‘XData’, time(1:i));
end
% Update plot for raw signal
set(h_raw, ‘YData’, x(1:i), ‘XData’, time(1:i));
drawnow;
end
save(‘EMG_data.mat’, ‘x’,);
It doesn’t create the .mat file and I suppose the problem is that i stop the iteration very early. But I want to save any values that are obtained until any iteration. How can I fix that? save variable from workspace, iterations MATLAB Answers — New Questions