plotting PPG signal using PWL source
13 次查看(过去 30 天)
显示 更早的评论
hello sir ,
i want to plot PPG signal .csv or xlsx file using PWL source to plot ,
- i have imported the datasheet to the editor ,how can we make variables that can be seen by simulink , PWL source ??
- COULD the PWL source accept variables ?
i bulit the circiut consisting of : (PWL source - voltage sensor - PS simulink - scope ) to show the waveforn but it doesn't work -need solver config-
is there any another solution ??
excue me for my weak english
thanks
回答(1 个)
Prasanna
2024-10-21
编辑:Prasanna
2024-10-21
Hi abd-elRaoof,
To plot a PPG signal from a source file using a piecewise linear (PWL) source in Simulink, you can do the following steps:
- Load the PPG signal data file into MATLAB using ‘readmatrix’ and extract the corresponding time and signal values from the data.
- After preparing the data for PWL source where the first column is time and second column is the signal value, configure the PWL source in Simulink and set the PWL vector of time-value pairs parameter to the PWL data.
- Add a solver configuration block, connect the PWL source to the rest of the circuit and run the simulation to visualize the PPG result.
A sample code assuming the data is present in a file named ‘data.csv’ with the first column as time and second column as signal and a Simulink model with the name ‘sim_model’ is given below:
% Load data
data = readmatrix('data.csv');
time = data(:, 1);
signal = data(:, 2);
% Prepare PWL data
pwl_data = [time, signal];
% Open Simulink model
open_system('sim_model');
% Set PWL Source data
set_param('sim_model/PWL Source', 'PWLVector', 'pwl_data');
% Run the simulation
sim('sim_model');
Some other points you can check if the waveform doesn’t show is to check the solver configuration connections and making sure that the ‘pwl_data’ variable is in the MATLAB workspace when running the Simulink model. If the PWL source is problematic, consider using a ‘From Workspace’ block to import data directly into Simulink. For more information on the functions used, refer the following documentations:
0 个评论
另请参阅
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!