how to read ECG data in similink ?
7 views (last 30 days)
Show older comments
i have this code in MAtlab load ('sel100m.mat') % the signal will be loaded to "val" matrix val = (val - 1024)/200; % you have to remove "base" and "gain" ecg = val(1,1:1000); % select the lead (Lead I) fs = 360; % sampling frequecy t = (0:length(ecg)-1)/fs; % time plot (t, ecg); and when i try to similiate with block from workspace i have this message Invalid matrix-format variable specified as workspace input in 'untitled/From Workspace'. The matrix must have two dimensions and at least two columns. Complex signals of any data type and non-double real signals must be in structure format. The first column must contain time values and the remaining columns the data values. Matrix values cannot be Inf or NaN. can you help me, thank you.
0 Comments
Answers (1)
Himanshu
on 28 Oct 2024 at 5:53
Hey Alice,
The error message you're encountering indicates that the input data for the "From Workspace" block in Simulink needs to be formatted such that it is a matrix where the first column contains time values and the subsequent columns contain the corresponding data values.
You already have the required data, all you need is to transpose 't' and 'ecg' and combine them into a single matrix.
% Combine time and data into a single matrix
simulink_input = [t' ecg']; % transpose to ensure columns
Now, you can use 'simulink_input' as the input for the "From Workspace" block in Simulink.
Hope this helps!
0 Comments
See Also
Categories
Find more on ECG / EKG in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!