How to use From Workspace block to import excel data in simulink and then plot in scope?

조회 수: 1 (최근 30일)
I am trying to export a excel data into simulink using From Workspace block. But when I plot the data using scope in simulink,I am getting different graph.

답변 (1개)

Shuba Nandini
Shuba Nandini 2024년 12월 26일
Hi,
To plot the excel data using "From Workspace" and "Scope" blocks, please refer to the following steps:
  • Assuming the Excel data is structured with one column for time and another for signal values, you can use the following script to read the data from Excel file:
% Load data from the Excel sheet
data = readtable('exampledata.xlsx');
% Extract time and signal data
time = data.Time;
signal = data.Signal;
% Create a data structure
simulationData = struct('time', time, 'signals', struct('values', signal, 'dimensions', 1));
% Save this structure to the workspace
assignin('base', 'simulationData', simulationData);
  • Open Simulink and drag the 'From Workspace' block.
  • Double-click on the block and set the Variable name to simulationData.
  • Drag a 'Scope' block and connect its input to the 'From Workspace' block to plot the data.
  • Press Run in Simulink to start the simulation and click on the 'Scope' block to view the plot.
I hope this helps you to plot the data!

카테고리

Help CenterFile Exchange에서 Sources에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by