how can import data excel to scope in simulink? (plot charts)

조회 수: 5 (최근 30일)
af af
af af 2022년 1월 18일
답변: Udit06 2024년 8월 30일
0.047418 0.485851
0.111818 0.581864
0.07743 0.526557
0.185357 0.675541
0.159962 0.623343
0.820219 0.724674
1.728073 0.731636
2.635927 0.742078
3.543781 0.753874
4.451635 0.766057

답변 (1개)

Udit06
Udit06 2024년 8월 30일
Hi,
You can follow the steps below to visualize Excel sheet data in Scope block in Simulink:
1) Load the excel sheet in form of a table in MATLAB workspace. You can refer to the following MathWorks documentation to understand more about how to load Excel sheet data in the workspace:
2) Since you want to plot two variables let us say a and b, you can create a time vector which can be used as a common time reference for both the variables.
%Book2 is the name of the table
% Create a time vector from 1 to 10
time = 1:1:10;
% Assign data from Book2.VarName1 to variable a
a = Book2.VarName1;
% Assign data from Book2.VarName2 to variable b
b = Book2.VarName2;
% Concatenate the time vector with a to form a 10-by-2 matrix
a = [time' a];
% Concatenate the time vector with b to form another 10-by-2 matrix
b = [time' b];
3) You can use Simulink's From Workspace block to input data from workspace into Simulink. Connect the output of the From Workspace blocks to the input of the Scope block as shown below:
4) Simulate the model and view the output of the Scope block. For the data that I have used, the output is shown below:
I hope this helps.

카테고리

Help CenterFile Exchange에서 Data Import from MATLAB에 대해 자세히 알아보기

Community Treasure Hunt

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

Start Hunting!

Translated by