how to read ECG data in similink ?

3 visualizzazioni (ultimi 30 giorni)
alice ayoub
alice ayoub il 17 Mag 2017
Risposto: Himanshu il 28 Ott 2024
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.

Risposte (1)

Himanshu
Himanshu il 28 Ott 2024
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!

Categorie

Scopri di più su Simulink in Help Center e File Exchange

Community Treasure Hunt

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

Start Hunting!

Translated by